pax_global_header00006660000000000000000000000064141554413120014512gustar00rootroot0000000000000052 comment=1bee290ce5efff0e0f2bbb074b4e85ad9451d123 strftime-0.10.1/000077500000000000000000000000001415544131200134265ustar00rootroot00000000000000strftime-0.10.1/.gitignore000066400000000000000000000000261415544131200154140ustar00rootroot00000000000000*.tmproj node_modules strftime-0.10.1/Changelog.md000066400000000000000000000212771415544131200156500ustar00rootroot00000000000000v0.10.1 on 2021-12-12 --------------------- - Fix it_IT shortMonths locale Thanks to [Douglas de Espindola](https://github.com/douglasep) - Try to get a short time zone name for %Z, falling back to the long one. This attempts to work around a change to Date.toString in v8 (node v10+, Chrome 66+). Unfortunately sometimes Date.toLocaleString returns a time zone like GMT+2 and we fall back to the long name in that case. v0.10.0 on 2016-12-28 --------------------- - Remove the old API deprecated in v0.9. - Bundle some locales that you can use with `strftime.localizeByIdentifier('nl_NL')`. Full list available in the [readme](https://github.com/samsonjs/strftime/blob/master/Readme.md). Thanks to [Andrew Pirondini](https://github.com/andrewjpiro) of [iFixit](https://ifixit.com) - Add instructions to install with Yarn. Thanks to [Ayman Nedjmeddine](https://github.com/IOAyman) - Unrecognized format specifiers preserve the % sign, e.g. `strftime('%K') => "%K"`. Thanks to [Kevin Jin](https://github.com/Kevin-Jin) - Make `strftime` work with dates that have been extended by [DateJS](http://www.datejs.com). Thanks to [Stian Grytøyr](https://github.com/stiang) - Add instructions to install with Yarn. Thanks to [Ayman Nedjmeddine](https://github.com/IOAyman) - Fix UTC formatting of dates that cross a DST boundary. Thanks to [ray007](https://github.com/ray007) - Allow localizing ordinals. Thanks to [Simon Liétar](https://github.com/Sim9760) v0.9.2 on 2015-05-29 -------------------- - fix a caching bug, which was a regression in 0.9.0 ([issue #63](https://github.com/samsonjs/strftime/issues/63)) - update license attribute in package.json as required by npm Thanks to [Peter deHaan](https://github.com/pdehaan) - construct GMT times used in tests in a more robust way - fix a bug calculating week numbers ([issue #56](https://github.com/samsonjs/strftime/issues/56)) Thanks to [Alexandr Nikitin](https://github.com/alexandrnikitin) - warn about possible misuse of %:: or %::: modifiers v0.9.1 on 2015-03-16 -------------------- - re-fix [issue #38](https://github.com/samsonjs/strftime/pull/38) which was lost in the v0.9 merge - add this changelog v0.9.0 on 2015-03-15 -------------------- This release marks the final run up to v1.0, which should be released by March 2016. The headline feature is a huge performance boost resulting from [this contest](http://hola.org/challenge_js). [Alexandr Nikitin](https://github.com/alexandrnikitin) has essentially [rewritten](https://github.com/samsonjs/strftime/pull/41) the code and [the results](http://jsperf.com/strftime-optimization/2) speak for themselves. Along with this the API has been unified and cleaned up. `strftimeTZ`, `strftimeUTC`, and `localizedStrftime` have all been deprecated in favour of the following functions: `timezone(tz)`, `utc()`, and `localize(locale)`. You use them like so: ```JavaScript var strftime = require('strftime'); // not required in web browsers var strftimeIT = strftime.localize(anItalianLocale); var strftimePST = strftime.timezone('-0800'); var strftimeUTC = strftime.utc(); // You can combine them var strftimeIT_PST = strftimeIT.timezone('-0800'); // And chain them all at once var strftimeIT_PST = strftime.localize(anItalianLocale).timezone('-0800'); ``` The previous API is deprecated and will be removed for v1.0. The good news is that the previous API is supported by adapting the new API, so you get most of the performance benefits before you even update your code to use the new API. The new API does not support passing in a custom timezone or locale on each call to `strftime`. This is a regression so if you really need this use case [let us know](https://github.com/samsonjs/strftime/issues/new) and we'll figure something out. Thanks to all contributors that have helped to improve this library over the past 4 years. v0.8.4 on 2015-03-05 -------------------- - fix conversion of dates to UTC Thanks to [Alexandr Nikitin](https://github.com/alexandrnikitin) - extend `%z` with a colon separator in timezone offsets, `"[+-]HH:MM"` Thanks to [Cory Heslip](https://github.com/cheslip) - ignore irrelevant files in bower.json v0.8.3 on 2015-02-08 -------------------- First release for [Bower](http://bower.io), and only released for Bower. v0.8.2 on 2014-08-08 -------------------- - fix `%e` which is supposed to be padded with a space v0.8.1 on 2014-06-17 -------------------- - fix `%Z` when the timezone contains spaces Thanks to [w0den](https://github.com/w0den) - fix examples using `%Y` in the readme Thanks to [Ryan Regalado](https://github.com/d48) - fix a bug when specifying minutes in the timezone Thanks to [Alexandr Nikitin](https://github.com/alexandrnikitin) v0.8.0 on 2014-01-29 -------------------- - allow timezones to be specified as strings of the form `"+0100"` or `"-0800"` (`[+-]HHMM`) - fix a bug running tests where the environment variable `TZ` is empty and the system timezone is not PST/PDT v0.7.0 on 2013-11-08 -------------------- - add support for passing in explicit timezones with `strftimeTZ` which accepts numeric offsets from GMT, in minutes v0.6.2 on 2013-08-29 -------------------- - expose `strftimeUTC` and `localizedStrftime` properly in browsers v0.6.1 on 2013-06-13 -------------------- - fix a bug where `RequiredDateMethods` was created as a global v0.6.0 on 2013-05-15 -------------------- - add `%o` to get the day of the month as an ordinal (in English) v0.5.2 on 2013-04-07 -------------------- - add some Ruby extension prefixes: `-`, `_`, and `0`, and they work like so: `strftime('%-d') // => "7"` `strftime('%_d') // => " 7"` `strftime('%0d') // => "07"` - fix padding the day-of-year in `%j` - add a minified version of the code to the repo for easy distribution with some package managers v0.5.1 on 2013-03-07 -------------------- - remove deprecated `getLocalizedStrftime` function - make `%C` pad the century with spaces, like C - list all supported specifiers in the readme, it's no longer fair to say "look at `man 3 strftime`" - use fixed dates in the readme instead of "now", so people can execute the examples and see the same results Thanks to [John Zwinck](https://github.com/jzwinck) - fix `%z` for timezones greater than GMT - support any `Date`-like objects instead of checking for actual instances of `Date` v0.5.0 on 2013-01-05 -------------------- - add week numbers `%U` and `%W` - add support for [component](https://github.com/componentjs/component) Thanks to [TJ Holowaychuk](https://github.com/tj) v0.4.8 on 2012-11-13 -------------------- - add `%j` and `%C`, thanks to [Ryan Stafford](https://github.com/ryanstafford) v0.4.7 on 2012-06-08 -------------------- - add `%P` which is "am" or "pm", like `%p` but lowercase (this makes no sense, and I am sorry for propagating this madness) Thanks to [Rob Colburn](https://github.com/robcolburn) - export the `strftime` function directly in [node](https://nodejs.org) so you can write `strftime = require('strftime')` instead of `strftime = require('strftime').strftime` - added contributors to the readme and package.json v0.4.6 on 2011-06-13 -------------------- - rename `getLocalizedStrftime(locale)` to `localizedStrftime(locale)` The old name is deprecated and will stick around until v0.5 or v0.6. - add tests for locales v0.4.5 on 2011-06-08 -------------------- - fix the sign of `%z`, which is something like "+0100" or "-0800" (`[+-]HHMM`) - improve test coverage v0.4.4 on 2011-06-07 -------------------- - fix `%L` for values < 100 - convert tests from CoffeeScript to JavaScript (nothing personal, just keeping the dependencies trim) v0.4.3 on 2011-06-05 -------------------- This release was all [Andrew Schaaf](https://github.com/andrewschaaf). - add some tests - fix `%s` which is seconds since the Unix epoch, but was in milliseconds - add `%L` for 3-digit milliseconds v0.4.2 on 2011-06-05 -------------------- - add `strftimeUTC` for ignoring timezones Thanks to [Andrew Schaaf](https://github.com/andrewschaaf) - support exporting to the top level object in ES5 strict mode v0.4.1 on 2011-06-02 -------------------- - fix `%y` for years outside the range [1900, 2099] v0.4.0 on 2011-04-28 -------------------- - add support for localization v0.3.0 on 2010-12-17 -------------------- - fix export for browsers v0.2.3 on 2010-12-15 -------------------- - set required [node](https://nodejs.org) version to 0.2 instead of 0.3 in package.json v0.2.2 on 2010-11-14 -------------------- - fix module export v0.2.1 on 2010-11-11 -------------------- - bug fix for recursive formats v0.2.0 on 2010-11-11 -------------------- - use `String.prototype.replace` instead of a `for` loop v0.1.0 on 2010-11-11 -------------------- Initial release.strftime-0.10.1/Makefile000066400000000000000000000005431415544131200150700ustar00rootroot00000000000000minify: real-minify test-minified real-minify: strftime.js rm -f strftime-min.js closure |strftime-min.js test: TZ=America/Vancouver node test.js TZ=Europe/Amsterdam node test.js test-minified: minify TZ=America/Vancouver node test.js ./strftime-min.js TZ=Europe/Amsterdam node test.js ./strftime-min.js .PHONY: test test-minified strftime-0.10.1/Readme.md000066400000000000000000000201711415544131200151460ustar00rootroot00000000000000strftime ======== strftime for JavaScript. Works in (at least) node.js and browsers. Supports localization and timezones. Most standard specifiers from C are supported as well as some other extensions from Ruby. [![version 0.10.1 on npm](https://img.shields.io/badge/npm-0.10.0-brightgreen.svg?style=flat)](https://www.npmjs.com/package/strftime) [![node version 0.2 and up](https://img.shields.io/badge/node->=0.2-brightgreen.svg?style=flat)](https://nodejs.org) [![MIT License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://sjs.mit-license.org) Installation ============ [node](https://nodejs.org): npm install strftime [bower](http://bower.io): bower install strftime [component](https://github.com/componentjs/component): component install samsonjs/strftime [yarn](https://yarnpkg.com): yarn add strftime Or you can copy [strftime.js](https://github.com/samsonjs/strftime/blob/master/strftime.js) wherever you want to use it, whether that's with a <script> tag or `require` or anything else. Changelog ========= [View the changelog](https://github.com/samsonjs/strftime/blob/master/Changelog.md). Usage ===== ```JavaScript var strftime = require('strftime') // not required in browsers console.log(strftime('%B %d, %Y %H:%M:%S')) // => April 28, 2011 18:21:08 console.log(strftime('%F %T', new Date(1307472705067))) // => 2011-06-07 18:51:45 ``` If you want to localize it: ```JavaScript var strftime = require('strftime') // not required in browsers var it_IT = { days: ['domenica', 'lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato'], shortDays: ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'], months: ['gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre'], shortMonths: ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { D: '%m/%d/%y', F: '%Y-%m-%d', R: '%H:%M', X: '%T', c: '%a %b %d %X %Y', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', x: '%D' } } var strftimeIT = strftime.localize(it_IT) console.log(strftimeIT('%B %d, %Y %H:%M:%S')) // => aprile 28, 2011 18:21:08 console.log(strftimeIT('%B %d, %Y %H:%M:%S', new Date(1307472705067))) // => giugno 7, 2011 18:51:45 ``` Some locales are bundled and can be used like so: ```JavaScript var strftime = require('strftime') // not required in browsers var strftimeIT = strftime.localizeByIdentifier('it_IT') console.log(strftimeIT('%B %d, %Y %H:%M:%S')) // => aprile 28, 2011 18:21:08 console.log(strftimeIT('%B %d, %Y %H:%M:%S', new Date(1307472705067))) // => giugno 7, 2011 18:51:45 ``` _The [full list of bundled locales](#locales) is below._ Time zones can be passed in as an offset from GMT in minutes. ```JavaScript var strftime = require('strftime') // not required in browsers var strftimePDT = strftime.timezone(-420) var strftimeCEST = strftime.timezone(120) console.log(strftimePDT('%B %d, %y %H:%M:%S', new Date(1307472705067))) // => June 07, 11 11:51:45 console.log(strftimeCEST('%F %T', new Date(1307472705067))) // => 2011-06-07 20:51:45 ``` Alternatively you can use the timezone format used by ISO 8601, `+HHMM` or `-HHMM`. ```JavaScript var strftime = require('strftime') // not required in browsers var strftimePDT = strftime.timezone('-0700') var strftimeCEST = strftime.timezone('+0200') console.log(strftimePDT('%F %T', new Date(1307472705067))) // => 2011-06-07 11:51:45 console.log(strftimeCEST('%F %T', new Date(1307472705067))) // => 2011-06-07 20:51:45 ``` Supported Specifiers ==================== Extensions from Ruby are noted in the following list. Unsupported specifiers are rendered without the percent sign. e.g. `%q` becomes `q`. Use `%%` to get a literal `%` sign. - A: full weekday name - a: abbreviated weekday name - B: full month name - b: abbreviated month name - C: AD century (year / 100), padded to 2 digits - c: equivalent to `%a %b %d %X %Y %Z` in en_US (based on locale) - D: equivalent to `%m/%d/%y` in en_US (based on locale) - d: day of the month, padded to 2 digits (01-31) - e: day of the month, padded with a leading space for single digit values (1-31) - F: equivalent to `%Y-%m-%d` in en_US (based on locale) - H: the hour (24-hour clock), padded to 2 digits (00-23) - h: the same as %b (abbreviated month name) - I: the hour (12-hour clock), padded to 2 digits (01-12) - j: day of the year, padded to 3 digits (001-366) - k: the hour (24-hour clock), padded with a leading space for single digit values (0-23) - L: the milliseconds, padded to 3 digits [Ruby extension] - l: the hour (12-hour clock), padded with a leading space for single digit values (1-12) - M: the minute, padded to 2 digits (00-59) - m: the month, padded to 2 digits (01-12) - n: newline character - o: day of the month as an ordinal (without padding), e.g. 1st, 2nd, 3rd, 4th, ... - P: "am" or "pm" in lowercase (Ruby extension, based on locale) - p: "AM" or "PM" (based on locale) - R: equivalent to `%H:%M` in en_US (based on locale) - r: equivalent to `%I:%M:%S %p` in en_US (based on locale) - S: the second, padded to 2 digits (00-60) - s: the number of seconds since the Epoch, UTC - T: equivalent to `%H:%M:%S` in en_US (based on locale) - t: tab character - U: week number of the year, Sunday as the first day of the week, padded to 2 digits (00-53) - u: the weekday, Monday as the first day of the week (1-7) - v: equivalent to `%e-%b-%Y` in en_US (based on locale) - W: week number of the year, Monday as the first day of the week, padded to 2 digits (00-53) - w: the weekday, Sunday as the first day of the week (0-6) - X: equivalent to `%T` or `%r` in en_US (based on locale) - x: equivalent to `%D` in en_US (based on locale) - Y: the year with the century - y: the year without the century (00-99) - Z: the time zone name, replaced with an empty string if it is not found - z: the time zone offset from UTC, with a leading plus sign for UTC and zones east of UTC and a minus sign for those west of UTC, hours and minutes follow each padded to 2 digits and with no delimiter between them For more detail see `man 3 strftime` as the format specifiers should behave identically. If behaviour differs please [file a bug](https://github.com/samsonjs/strftime/issues/new). Any specifier can be modified with `-`, `_`, `0`, or `:` as well, as in Ruby. Using `%-` will omit any leading zeroes or spaces, `%_` will force spaces for padding instead of the default, and `%0` will force zeroes for padding. There's some redundancy here as `%-d` and `%e` have the same result, but it solves some awkwardness with formats like `%l`. Using `%:` for time zone offset, as in `%:z` will insert a colon as a delimiter. Bundled Locales =============== - de\_DE - en\_CA - en\_US - es\_MX - fr\_FR - it\_IT - nl\_NL - pt\_BR - ru\_RU - tr\_TR - zh\_CN Contributors ============ * [Alexandr Nikitin](https://github.com/alexandrnikitin) * [Andrew Pirondini](https://github.com/andrewjpiro) of [iFixit](https://github.com/iFixit) * [Andrew Schaaf](https://github.com/andrewschaaf) * [Ayman Nedjmeddine](https://github.com/IOAyman) * [Cory Heslip](https://github.com/cheslip) * [Douglas de Espindola](https://github.com/douglasep) * [Forbes Lindesay](https://github.com/ForbesLindesay) * [John Zwinck](https://github.com/jzwinck) * [Joost Hietbrink](https://github.com/joost) * [Kevin Jin](https://github.com/Kevin-Jin) * [Michael J.](https://github.com/michaeljayt) * [Peter deHaan](https://github.com/pdehaan) * [Rob Colburn](https://github.com/robcolburn) * [Ryan Regalado](https://github.com/d48) * [Ryan Stafford](https://github.com/ryanstafford) * [Sami Samhuri](https://github.com/samsonjs) * [Stian Grytøyr](https://github.com/stiang) * [TJ Holowaychuk](https://github.com/tj) * [w0den](https://github.com/w0den) License ======= Copyright 2010 - 2021 Sami Samhuri sami@samhuri.net [MIT license](https://sjs.mit-license.org) strftime-0.10.1/bower.json000066400000000000000000000003041415544131200154340ustar00rootroot00000000000000{ "name": "strftime", "version": "0.10.1", "main": "strftime.js", "ignore": [ "Readme.md", "Makefile", "test", "*.json" ], "dependencies": {}, "devDependencies": {} }strftime-0.10.1/component.json000066400000000000000000000003511415544131200163220ustar00rootroot00000000000000{ "name": "strftime", "repo": "samsonjs/strftime", "description": "strftime date formatting", "keywords": ["strftime", "format", "date", "time"], "version": "0.10.1", "main": "strftime.js", "scripts": ["strftime.js"] } strftime-0.10.1/package.json000066400000000000000000000032461415544131200157210ustar00rootroot00000000000000{ "name": "strftime", "description": "strftime for JavaScript", "version": "0.10.1", "homepage": "https://samhuri.net/projects/strftime", "author": "Sami Samhuri ", "contributors": [ "Alexandr Nikitin (https://github.com/alexandrnikitin)", "Andrew Pirondini of iFixit (https://github.com/andrewjpiro)", "Andrew Schaaf (https://github.com/andrewschaaf)", "Ayman Nedjmeddine (https://github.com/IOAyman)", "Cory Heslip (https://github.com/cheslip)", "Douglas de Espindola (https://github.com/douglasep)", "Forbes Lindesay (https://github.com/ForbesLindesay)", "John Zwinck (https://github.com/jzwinck)", "Joost Hietbrink (https://github.com/joost)", "Kevin Jin (https://github.com/Kevin-Jin)", "Michael J. (https://github.com/michaeljayt)", "Peter deHaan (https://github.com/pdehaan)", "Rob Colburn (https://github.com/robcolburn)", "Ryan Regalado (https://github.com/d48)", "Ryan Stafford (https://github.com/ryanstafford)", "Sami Samhuri (https://github.com/samsonjs)", "Stian Grytøyr (https://github.com/stiang)", "TJ Holowaychuk (https://github.com/tj)", "w0den (https://github.com/w0den)" ], "keywords": ["strftime", "format", "string", "time", "date"], "repository": { "type": "git", "url": "git://github.com/samsonjs/strftime.git" }, "bugs": { "email": "sami@samhuri.net", "url": "https://github.com/samsonjs/strftime/issues" }, "main": "./strftime.js", "engines": { "node": ">=0.2.0" }, "license": "MIT", "dependencies": {}, "devDependencies": {}, "optionalDependencies": {} } strftime-0.10.1/strftime-min.js000066400000000000000000000260521415544131200164070ustar00rootroot00000000000000(function(){function q(c,g,n){function i(c,a,e,f){for(var b="",d=null,g=!1,l=c.length,n=!1,j=0;j99?Math.floor(f%1E3):Math.floor(f%1E3)>9?"0"+Math.floor(f%1E3):"00"+Math.floor(f%1E3);break;case 77:b+=h(a.getMinutes(),d);break;case 80:b+=a.getHours()<12?e.am:e.pm;break;case 82:b+=i(e.formats.R,a,e,f);break;case 83:b+=h(a.getSeconds(),d);break;case 84:b+=i(e.formats.T,a,e,f);break;case 85:b+=h(v(a,"sunday"),d);break;case 87:b+=h(v(a,"monday"),d);break;case 88:b+=i(e.formats.X, a,e,f);break;case 89:b+=a.getFullYear();break;case 90:o&&k===0?b+="GMT":(d=a.toString().match(/\(([\w\s]+)\)/),b+=d&&d[1]||"");break;case 97:b+=e.shortDays[a.getDay()];break;case 98:b+=e.shortMonths[a.getMonth()];break;case 99:b+=i(e.formats.c,a,e,f);break;case 100:b+=h(a.getDate(),d);break;case 101:b+=h(a.getDate(),d==null?" ":d);break;case 104:b+=e.shortMonths[a.getMonth()];break;case 106:d=new Date(a.getFullYear(),0,1);d=Math.ceil((a.getTime()-d.getTime())/864E5);b+=d>99?d:d>9?"0"+d:"00"+d;break; case 107:b+=h(a.getHours(),d==null?" ":d);break;case 108:b+=h(u(a.getHours()),d==null?" ":d);break;case 109:b+=h(a.getMonth()+1,d);break;case 110:b+="\n";break;case 111:d=a.getDate();b+=e.ordinalSuffixes?String(d)+(e.ordinalSuffixes[d-1]||w(d)):String(d)+w(d);break;case 112:b+=a.getHours()<12?e.AM:e.PM;break;case 114:b+=i(e.formats.r,a,e,f);break;case 115:b+=Math.floor(f/1E3);break;case 116:b+="\t";break;case 117:d=a.getDay();b+=d===0?7:d;break;case 118:b+=i(e.formats.v,a,e,f);break;case 119:b+=a.getDay(); break;case 120:b+=i(e.formats.x,a,e,f);break;case 121:b+=(""+a.getFullYear()).slice(2);break;case 122:o&&k===0?b+=n?"+00:00":"+0000":(d=k!==0?k/6E4:-a.getTimezoneOffset(),g=n?":":"",m=Math.abs(d%60),b+=(d<0?"-":"+")+h(Math.floor(Math.abs(d/60)))+g+h(m));break;default:g&&(b+="%"),b+=c[j]}d=null;g=!1}else m===37?g=!0:b+=c[j]}return b}var j=c||x,k=g||0,o=n||!1,p=0,r,l=function(c,a){var e;if(a){if(e=a.getTime(),o){var f=(a.getTimezoneOffset()||0)*6E4,a=new Date(e+f+k);if((a.getTimezoneOffset()||0)*6E4!== f)f=(a.getTimezoneOffset()||0)*6E4,a=new Date(e+f+k)}}else e=Date.now(),e>p?(p=e,r=new Date(p),e=p,o&&(r=new Date(p+(r.getTimezoneOffset()||0)*6E4+k))):e=p,a=r;return i(c,a,j,e)};l.localize=function(c){return new q(c||j,k,o)};l.localizeByIdentifier=function(c){var a=y[c];return!a?(t('[WARNING] No locale found with identifier "'+c+'".'),l):l.localize(a)};l.timezone=function(c){var a=k,e=o,f=typeof c;if(f==="number"||f==="string")e=!0,f==="string"?(a=c[0]==="-"?-1:1,f=parseInt(c.slice(1,3),10),c=parseInt(c.slice(3, 5),10),a=a*(60*f+c)*6E4):f==="number"&&(a=c*6E4);return new q(j,a,e)};l.utc=function(){return new q(j,k,!0)};return l}function h(c,g){if(g===""||c>9)return c;g==null&&(g="0");return g+c}function u(c){if(c===0)return 12;else if(c>12)return c-12;return c}function v(c,g){var g=g||"sunday",h=c.getDay();g==="monday"&&(h===0?h=6:h--);var i=Date.UTC(c.getFullYear(),0,1),j=Date.UTC(c.getFullYear(),c.getMonth(),c.getDate());return Math.floor((Math.floor((j-i)/864E5)+7-h)/7)}function w(c){var g=c%10;c%=100; if(c>=11&&c<=13||g===0||g>=4)return"th";switch(g){case 1:return"st";case 2:return"nd";case 3:return"rd"}}function t(c){typeof console!=="undefined"&&typeof console.warn=="function"&&console.warn(c)}var y={de_DE:{days:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],shortDays:["So","Mo","Di","Mi","Do","Fr","Sa"],months:["Januar","Februar","M\u00e4rz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],shortMonths:["Jan","Feb","M\u00e4r","Apr", "Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d.%m.%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},en_CA:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr", "May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ordinalSuffixes:["st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d/%m/%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%r",x:"%D"}},en_US:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu", "Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ordinalSuffixes:["st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%m/%d/%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p", T:"%H:%M:%S",v:"%e-%b-%Y",X:"%r",x:"%D"}},es_MX:{days:["domingo","lunes","martes","mi\u00e9rcoles","jueves","viernes","s\u00e1bado"],shortDays:["dom","lun","mar","mi\u00e9","jue","vie","s\u00e1b"],months:["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre"," diciembre"],shortMonths:["ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d/%m/%Y",F:"%Y-%m-%d",R:"%H:%M", r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},fr_FR:{days:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"],shortDays:["dim.","lun.","mar.","mer.","jeu.","ven.","sam."],months:["janvier","f\u00e9vrier","mars","avril","mai","juin","juillet","ao\u00fbt","septembre","octobre","novembre","d\u00e9cembre"],shortMonths:["janv.","f\u00e9vr.","mars","avril","mai","juin","juil.","ao\u00fbt","sept.","oct.","nov.","d\u00e9c."],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z", D:"%d/%m/%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},it_IT:{days:["domenica","luned\u00ec","marted\u00ec","mercoled\u00ec","gioved\u00ec","venerd\u00ec","sabato"],shortDays:["dom","lun","mar","mer","gio","ven","sab"],months:["gennaio","febbraio","marzo","aprile","maggio","giugno","luglio","agosto","settembre","ottobre","novembre","dicembre"],shortMonths:["pr","mag","giu","lug","ago","set","ott","nov","dic"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z", D:"%d/%m/%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},nl_NL:{days:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],shortDays:["zo","ma","di","wo","do","vr","za"],months:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],shortMonths:["jan","feb","mrt","apr","mei","jun","jul","aug","sep","okt","nov","dec"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z",D:"%d-%m-%y", F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},pt_BR:{days:["domingo","segunda","ter\u00e7a","quarta","quinta","sexta","s\u00e1bado"],shortDays:["Dom","Seg","Ter","Qua","Qui","Sex","S\u00e1b"],months:["janeiro","fevereiro","mar\u00e7o","abril","maio","junho","julho","agosto","setembro","outubro","novembro","dezembro"],shortMonths:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X %Z", D:"%d-%m-%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},ru_RU:{days:["\u0412\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435","\u041f\u043e\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u0438\u043a","\u0412\u0442\u043e\u0440\u043d\u0438\u043a","\u0421\u0440\u0435\u0434\u0430","\u0427\u0435\u0442\u0432\u0435\u0440\u0433","\u041f\u044f\u0442\u043d\u0438\u0446\u0430","\u0421\u0443\u0431\u0431\u043e\u0442\u0430"],shortDays:["\u0412\u0441","\u041f\u043d","\u0412\u0442", "\u0421\u0440","\u0427\u0442","\u041f\u0442","\u0421\u0431"],months:["\u042f\u043d\u0432\u0430\u0440\u044c","\u0424\u0435\u0432\u0440\u0430\u043b\u044c","\u041c\u0430\u0440\u0442","\u0410\u043f\u0440\u0435\u043b\u044c","\u041c\u0430\u0439","\u0418\u044e\u043d\u044c","\u0418\u044e\u043b\u044c","\u0410\u0432\u0433\u0443\u0441\u0442","\u0421\u0435\u043d\u0442\u044f\u0431\u0440\u044c","\u041e\u043a\u0442\u044f\u0431\u0440\u044c","\u041d\u043e\u044f\u0431\u0440\u044c","\u0414\u0435\u043a\u0430\u0431\u0440\u044c"], shortMonths:["\u044f\u043d\u0432","\u0444\u0435\u0432","\u043c\u0430\u0440","\u0430\u043f\u0440","\u043c\u0430\u0439","\u0438\u044e\u043d","\u0438\u044e\u043b","\u0430\u0432\u0433","\u0441\u0435\u043d","\u043e\u043a\u0442","\u043d\u043e\u044f","\u0434\u0435\u043a"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{c:"%a %d %b %Y %X",D:"%d.%m.%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T",x:"%D"}},tr_TR:{days:["Pazar","Pazartesi","Sal\u0131","\u00c7ar\u015famba","Per\u015fembe", "Cuma","Cumartesi"],shortDays:["Paz","Pzt","Sal","\u00c7r\u015f","Pr\u015f","Cum","Cts"],months:["Ocak","\u015eubat","Mart","Nisan","May\u0131s","Haziran","Temmuz","A\u011fustos","Eyl\u00fcl","Ekim","Kas\u0131m","Aral\u0131k"],shortMonths:["Oca","\u015eub","Mar","Nis","May","Haz","Tem","A\u011fu","Eyl","Eki","Kas","Ara"],AM:"\u00d6\u00d6",PM:"\u00d6S",am:"\u00d6\u00d6",pm:"\u00d6S",formats:{c:"%a %d %b %Y %X %Z",D:"%d-%m-%Y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%T", x:"%D"}},zh_CN:{days:["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"],shortDays:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],months:["\u4e00\u6708\u4efd","\u4e8c\u6708\u4efd","\u4e09\u6708\u4efd","\u56db\u6708\u4efd","\u4e94\u6708\u4efd","\u516d\u6708\u4efd","\u4e03\u6708\u4efd","\u516b\u6708\u4efd","\u4e5d\u6708\u4efd","\u5341\u6708\u4efd","\u5341\u4e00\u6708\u4efd","\u5341\u4e8c\u6708\u4efd"], shortMonths:["\u4e00\u6708","\u4e8c\u6708","\u4e09\u6708","\u56db\u6708","\u4e94\u6708","\u516d\u6708","\u4e03\u6708","\u516b\u6708","\u4e5d\u6708","\u5341\u6708","\u5341\u4e00\u6708","\u5341\u4e8c\u6708"],AM:"\u4e0a\u5348",PM:"\u4e0b\u5348",am:"\u4e0a\u5348",pm:"\u4e0b\u5348",formats:{c:"%a %d %b %Y %X %Z",D:"%d/%m/%y",F:"%Y-%m-%d",R:"%H:%M",r:"%I:%M:%S %p",T:"%H:%M:%S",v:"%e-%b-%Y",X:"%r",x:"%D"}}},x=y.en_US,z=new q(x,0,!1),s;typeof module!=="undefined"?s=module.exports=z:(s=function(){return this|| (0,eval)("this")}(),s.strftime=z);if(typeof Date.now!=="function")Date.now=function(){return+new Date}})(); strftime-0.10.1/strftime.js000066400000000000000000000772371415544131200156410ustar00rootroot00000000000000// // strftime // github.com/samsonjs/strftime // @_sjs // // Copyright 2010 - 2021 Sami Samhuri // // MIT License // http://sjs.mit-license.org // ;(function() { var Locales = { de_DE: { identifier: 'de-DE', days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'], shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'], months: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], shortMonths: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d.%m.%Y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, en_CA: { identifier: 'en-CA', days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ], shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ordinalSuffixes: [ 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st' ], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d/%m/%y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%r', x: '%D' } }, en_US: { identifier: 'en-US', days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ], shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], ordinalSuffixes: [ 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st' ], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%m/%d/%y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%r', x: '%D' } }, es_MX: { identifier: 'es-MX', days: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'], shortDays: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb'], months: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre',' diciembre'], shortMonths: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d/%m/%Y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, fr_FR: { identifier: 'fr-FR', days: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'], shortDays: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'], months: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'], shortMonths: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d/%m/%Y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, it_IT: { identifier: 'it-IT', days: ['domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato'], shortDays: ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'], months: ['gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre'], shortMonths: ['gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d/%m/%Y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, nl_NL: { identifier: 'nl-NL', days: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'], shortDays: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'], months: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'], shortMonths: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d-%m-%y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, pt_BR: { identifier: 'pt-BR', days: ['domingo', 'segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado'], shortDays: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'], months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'], shortMonths: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X %Z', D: '%d-%m-%Y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, ru_RU: { identifier: 'ru-RU', days: ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'], shortDays: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'], months: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'], shortMonths: ['янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек'], AM: 'AM', PM: 'PM', am: 'am', pm: 'pm', formats: { c: '%a %d %b %Y %X', D: '%d.%m.%y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, tr_TR: { identifier: 'tr-TR', days: ['Pazar', 'Pazartesi', 'Salı','Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'], shortDays: ['Paz', 'Pzt', 'Sal', 'Çrş', 'Prş', 'Cum', 'Cts'], months: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'], shortMonths: ['Oca', 'Şub', 'Mar', 'Nis', 'May', 'Haz', 'Tem', 'Ağu', 'Eyl', 'Eki', 'Kas', 'Ara'], AM: 'ÖÖ', PM: 'ÖS', am: 'ÖÖ', pm: 'ÖS', formats: { c: '%a %d %b %Y %X %Z', D: '%d-%m-%Y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%T', x: '%D' } }, // By michaeljayt // https://github.com/michaeljayt/strftime/commit/bcb4c12743811d51e568175aa7bff3fd2a77cef3 zh_CN: { identifier: 'zh-CN', days: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'], shortDays: ['日', '一', '二', '三', '四', '五', '六'], months: ['一月份', '二月份', '三月份', '四月份', '五月份', '六月份', '七月份', '八月份', '九月份', '十月份', '十一月份', '十二月份'], shortMonths: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], AM: '上午', PM: '下午', am: '上午', pm: '下午', formats: { c: '%a %d %b %Y %X %Z', D: '%d/%m/%y', F: '%Y-%m-%d', R: '%H:%M', r: '%I:%M:%S %p', T: '%H:%M:%S', v: '%e-%b-%Y', X: '%r', x: '%D' } } }; var DefaultLocale = Locales['en_US'], defaultStrftime = new Strftime(DefaultLocale, 0, false), isCommonJS = typeof module !== 'undefined', namespace; // CommonJS / Node module if (isCommonJS) { namespace = module.exports = defaultStrftime; } // Browsers and other environments else { // Get the global object. Works in ES3, ES5, and ES5 strict mode. namespace = (function() { return this || (1,eval)('this'); }()); namespace.strftime = defaultStrftime; } // Polyfill Date.now for old browsers. if (typeof Date.now !== 'function') { Date.now = function() { return +new Date(); }; } function Strftime(locale, customTimezoneOffset, useUtcTimezone) { var _locale = locale || DefaultLocale, _customTimezoneOffset = customTimezoneOffset || 0, _useUtcBasedDate = useUtcTimezone || false, // we store unix timestamp value here to not create new Date() each iteration (each millisecond) // Date.now() is 2 times faster than new Date() // while millisecond precise is enough here // this could be very helpful when strftime triggered a lot of times one by one _cachedDateTimestamp = 0, _cachedDate; function _strftime(format, date) { var timestamp; if (!date) { var currentTimestamp = Date.now(); if (currentTimestamp > _cachedDateTimestamp) { _cachedDateTimestamp = currentTimestamp; _cachedDate = new Date(_cachedDateTimestamp); timestamp = _cachedDateTimestamp; if (_useUtcBasedDate) { // how to avoid duplication of date instantiation for utc here? // we tied to getTimezoneOffset of the current date _cachedDate = new Date(_cachedDateTimestamp + getTimestampToUtcOffsetFor(_cachedDate) + _customTimezoneOffset); } } else { timestamp = _cachedDateTimestamp; } date = _cachedDate; } else { timestamp = date.getTime(); if (_useUtcBasedDate) { var utcOffset = getTimestampToUtcOffsetFor(date); date = new Date(timestamp + utcOffset + _customTimezoneOffset); // If we've crossed a DST boundary with this calculation we need to // adjust the new date accordingly or it will be off by an hour in UTC. if (getTimestampToUtcOffsetFor(date) !== utcOffset) { var newUTCOffset = getTimestampToUtcOffsetFor(date); date = new Date(timestamp + newUTCOffset + _customTimezoneOffset); } } } return _processFormat(format, date, _locale, timestamp); } function _processFormat(format, date, locale, timestamp) { var resultString = '', padding = null, isInScope = false, length = format.length, extendedTZ = false; for (var i = 0; i < length; i++) { var currentCharCode = format.charCodeAt(i); if (isInScope === true) { // '-' if (currentCharCode === 45) { padding = ''; continue; } // '_' else if (currentCharCode === 95) { padding = ' '; continue; } // '0' else if (currentCharCode === 48) { padding = '0'; continue; } // ':' else if (currentCharCode === 58) { if (extendedTZ) { warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"); } extendedTZ = true; continue; } switch (currentCharCode) { // Examples for new Date(0) in GMT // '%' // case '%': case 37: resultString += '%'; break; // 'Thursday' // case 'A': case 65: resultString += locale.days[date.getDay()]; break; // 'January' // case 'B': case 66: resultString += locale.months[date.getMonth()]; break; // '19' // case 'C': case 67: resultString += padTill2(Math.floor(date.getFullYear() / 100), padding); break; // '01/01/70' // case 'D': case 68: resultString += _processFormat(locale.formats.D, date, locale, timestamp); break; // '1970-01-01' // case 'F': case 70: resultString += _processFormat(locale.formats.F, date, locale, timestamp); break; // '00' // case 'H': case 72: resultString += padTill2(date.getHours(), padding); break; // '12' // case 'I': case 73: resultString += padTill2(hours12(date.getHours()), padding); break; // '000' // case 'L': case 76: resultString += padTill3(Math.floor(timestamp % 1000)); break; // '00' // case 'M': case 77: resultString += padTill2(date.getMinutes(), padding); break; // 'am' // case 'P': case 80: resultString += date.getHours() < 12 ? locale.am : locale.pm; break; // '00:00' // case 'R': case 82: resultString += _processFormat(locale.formats.R, date, locale, timestamp); break; // '00' // case 'S': case 83: resultString += padTill2(date.getSeconds(), padding); break; // '00:00:00' // case 'T': case 84: resultString += _processFormat(locale.formats.T, date, locale, timestamp); break; // '00' // case 'U': case 85: resultString += padTill2(weekNumber(date, 'sunday'), padding); break; // '00' // case 'W': case 87: resultString += padTill2(weekNumber(date, 'monday'), padding); break; // '16:00:00' // case 'X': case 88: resultString += _processFormat(locale.formats.X, date, locale, timestamp); break; // '1970' // case 'Y': case 89: resultString += date.getFullYear(); break; // 'GMT' // case 'Z': case 90: if (_useUtcBasedDate && _customTimezoneOffset === 0) { resultString += "GMT"; } else { var tzName = getTimezoneName(date); resultString += tzName || ''; } break; // 'Thu' // case 'a': case 97: resultString += locale.shortDays[date.getDay()]; break; // 'Jan' // case 'b': case 98: resultString += locale.shortMonths[date.getMonth()]; break; // '' // case 'c': case 99: resultString += _processFormat(locale.formats.c, date, locale, timestamp); break; // '01' // case 'd': case 100: resultString += padTill2(date.getDate(), padding); break; // ' 1' // case 'e': case 101: resultString += padTill2(date.getDate(), padding == null ? ' ' : padding); break; // 'Jan' // case 'h': case 104: resultString += locale.shortMonths[date.getMonth()]; break; // '000' // case 'j': case 106: var y = new Date(date.getFullYear(), 0, 1); var day = Math.ceil((date.getTime() - y.getTime()) / (1000 * 60 * 60 * 24)); resultString += padTill3(day); break; // ' 0' // case 'k': case 107: resultString += padTill2(date.getHours(), padding == null ? ' ' : padding); break; // '12' // case 'l': case 108: resultString += padTill2(hours12(date.getHours()), padding == null ? ' ' : padding); break; // '01' // case 'm': case 109: resultString += padTill2(date.getMonth() + 1, padding); break; // '\n' // case 'n': case 110: resultString += '\n'; break; // '1st' // case 'o': case 111: // Try to use an ordinal suffix from the locale, but fall back to using the old // function for compatibility with old locales that lack them. var day = date.getDate(); if (locale.ordinalSuffixes) { resultString += String(day) + (locale.ordinalSuffixes[day - 1] || ordinal(day)); } else { resultString += String(day) + ordinal(day); } break; // 'AM' // case 'p': case 112: resultString += date.getHours() < 12 ? locale.AM : locale.PM; break; // '12:00:00 AM' // case 'r': case 114: resultString += _processFormat(locale.formats.r, date, locale, timestamp); break; // '0' // case 's': case 115: resultString += Math.floor(timestamp / 1000); break; // '\t' // case 't': case 116: resultString += '\t'; break; // '4' // case 'u': case 117: var day = date.getDay(); resultString += day === 0 ? 7 : day; break; // 1 - 7, Monday is first day of the week // ' 1-Jan-1970' // case 'v': case 118: resultString += _processFormat(locale.formats.v, date, locale, timestamp); break; // '4' // case 'w': case 119: resultString += date.getDay(); break; // 0 - 6, Sunday is first day of the week // '12/31/69' // case 'x': case 120: resultString += _processFormat(locale.formats.x, date, locale, timestamp); break; // '70' // case 'y': case 121: resultString += ('' + date.getFullYear()).slice(2); break; // '+0000' // case 'z': case 122: if (_useUtcBasedDate && _customTimezoneOffset === 0) { resultString += extendedTZ ? "+00:00" : "+0000"; } else { var off; if (_customTimezoneOffset !== 0) { off = _customTimezoneOffset / (60 * 1000); } else { off = -date.getTimezoneOffset(); } var sign = off < 0 ? '-' : '+'; var sep = extendedTZ ? ':' : ''; var hours = Math.floor(Math.abs(off / 60)); var mins = Math.abs(off % 60); resultString += sign + padTill2(hours) + sep + padTill2(mins); } break; default: if (isInScope) { resultString += '%'; } resultString += format[i]; break; } padding = null; isInScope = false; continue; } // '%' if (currentCharCode === 37) { isInScope = true; continue; } resultString += format[i]; } return resultString; } var strftime = _strftime; strftime.localize = function(locale) { return new Strftime(locale || _locale, _customTimezoneOffset, _useUtcBasedDate); }; strftime.localizeByIdentifier = function(localeIdentifier) { var locale = Locales[localeIdentifier]; if (!locale) { warn('[WARNING] No locale found with identifier "' + localeIdentifier + '".'); return strftime; } return strftime.localize(locale); }; strftime.timezone = function(timezone) { var customTimezoneOffset = _customTimezoneOffset; var useUtcBasedDate = _useUtcBasedDate; var timezoneType = typeof timezone; if (timezoneType === 'number' || timezoneType === 'string') { useUtcBasedDate = true; // ISO 8601 format timezone string, [-+]HHMM if (timezoneType === 'string') { var sign = timezone[0] === '-' ? -1 : 1, hours = parseInt(timezone.slice(1, 3), 10), minutes = parseInt(timezone.slice(3, 5), 10); customTimezoneOffset = sign * ((60 * hours) + minutes) * 60 * 1000; // in minutes: 420 } else if (timezoneType === 'number') { customTimezoneOffset = timezone * 60 * 1000; } } return new Strftime(_locale, customTimezoneOffset, useUtcBasedDate); }; strftime.utc = function() { return new Strftime(_locale, _customTimezoneOffset, true); }; return strftime; } function padTill2(numberToPad, paddingChar) { if (paddingChar === '' || numberToPad > 9) { return numberToPad; } if (paddingChar == null) { paddingChar = '0'; } return paddingChar + numberToPad; } function padTill3(numberToPad) { if (numberToPad > 99) { return numberToPad; } if (numberToPad > 9) { return '0' + numberToPad; } return '00' + numberToPad; } function hours12(hour) { if (hour === 0) { return 12; } else if (hour > 12) { return hour - 12; } return hour; } // firstWeekday: 'sunday' or 'monday', default is 'sunday' // // Pilfered & ported from Ruby's strftime implementation. function weekNumber(date, firstWeekday) { firstWeekday = firstWeekday || 'sunday'; // This works by shifting the weekday back by one day if we // are treating Monday as the first day of the week. var weekday = date.getDay(); if (firstWeekday === 'monday') { if (weekday === 0) // Sunday weekday = 6; else weekday--; } var firstDayOfYearUtc = Date.UTC(date.getFullYear(), 0, 1), dateUtc = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()), yday = Math.floor((dateUtc - firstDayOfYearUtc) / 86400000), weekNum = (yday + 7 - weekday) / 7; return Math.floor(weekNum); } // Get the ordinal suffix for a number: st, nd, rd, or th function ordinal(number) { var i = number % 10; var ii = number % 100; if ((ii >= 11 && ii <= 13) || i === 0 || i >= 4) { return 'th'; } switch (i) { case 1: return 'st'; case 2: return 'nd'; case 3: return 'rd'; } } function getTimestampToUtcOffsetFor(date) { return (date.getTimezoneOffset() || 0) * 60000; } // Tries to get a short timezone name using Date.toLocaleString, falling back on the platform default // using Date.toString if necessary. function getTimezoneName(date, localeIdentifier) { return getShortTimezoneName(date, localeIdentifier) || getDefaultTimezoneName(date); } // Unfortunately this returns GMT+2 when running with `TZ=Europe/Amsterdam node test.js` so it's not // perfect. function getShortTimezoneName(date, localeIdentifier) { if (localeIdentifier == null) return null; var tzString = date .toLocaleString(localeIdentifier, { timeZoneName: 'short' }) .match(/\s([\w]+)$/); return tzString && tzString[1]; } // This varies by platform so it's not an ideal way to get the time zone name. On most platforms it's // a short name but in Node v10+ and Chrome 66+ it's a long name now. Prefer getShortTimezoneName(date) // where possible. function getDefaultTimezoneName(date) { var tzString = date.toString().match(/\(([\w\s]+)\)/); return tzString && tzString[1]; } function warn(message) { if (typeof console !== 'undefined' && typeof console.warn == 'function') { console.warn(message) } } }()); strftime-0.10.1/test.js000077500000000000000000000243601415544131200147530ustar00rootroot00000000000000#!/usr/bin/env node // Based on CoffeeScript by andrewschaaf on github // // TODO: // - past and future dates, especially < 1900 and > 2100 // - look for edge cases var assert = require('assert'), libFilename = process.argv[2] || './strftime.js', strftime = require(libFilename), strftimeUTC = strftime.utc(), Time = new Date(1307472705067); // Tue, 07 Jun 2011 18:51:45 GMT assert.fn = function(value, msg) { assert.equal(typeof value, 'function', msg); }; function assertFormat(time, format, expected, name, strftime) { var actual = strftime(format, time); assert.equal(actual, expected, name + '("' + format + '", ' + time + ') is ' + JSON.stringify(actual) + ', expected ' + JSON.stringify(expected)); } assert.format = function(format, expected, expectedUTC, time) { time = time || Time; if (expected) { assertFormat(time, format, expected, 'strftime', strftime); } assertFormat(time, format, expectedUTC || expected, 'strftime.utc()', strftimeUTC); }; /// check exports assert.fn(strftime.localize); assert.fn(strftime.timezone); assert.fn(strftime.utc); ok('Exports'); /// time zones if (process.env.TZ == 'America/Vancouver') { testTimezone('America/Vancouver'); assert.format('%C', '01', '01', new Date(100, 0, 1)); assert.format('%X', '11:51:45 AM', '06:51:45 PM'); assert.format('%c', 'Tue 07 Jun 2011 11:51:45 AM Pacific Daylight Time', 'Tue 07 Jun 2011 06:51:45 PM GMT'); assert.format('%j', '097', '098', new Date(1365390736236)); assert.format('%x', '06/07/11'); assert.format('%U', '12', null, new Date('2017-03-25 00:00:00 +0000')); assert.format('%U', '12', '13', new Date('2017-03-26 00:00:00 +0000')); assert.format('%U', '13', null, new Date('2017-03-27 00:00:00 +0000')); assert.format('%U', '13', '14', new Date('2017-04-02 00:00:00 +0000')); // Test dates crossing a DST boundary. var dstStart = +new Date('2016-11-06 01:50:00'); assert.format('%T', '01:50:00', '08:50:00', new Date(dstStart)) assert.format('%T', '01:00:00', '09:00:00', new Date(dstStart + 10 * 60 * 1000)) ok('Time zones (' + process.env.TZ + ')'); } else if (process.env.TZ == 'Europe/Amsterdam') { testTimezone('Europe/Amsterdam'); assert.format('%C', '01', '00', new Date(100, 0, 1)); assert.format('%X', '08:51:45 PM', '06:51:45 PM'); assert.format('%c', 'Tue 07 Jun 2011 08:51:45 PM Central European Summer Time', 'Tue 07 Jun 2011 06:51:45 PM GMT'); assert.format('%j', '098', '098', new Date(1365390736236)); assert.format('%x', '06/07/11'); assert.format('%U', '12', null, new Date('2017-03-25 00:00:00 +0000')); assert.format('%U', '13', null, new Date('2017-03-26 00:00:00 +0000')); assert.format('%U', '13', null, new Date('2017-03-27 00:00:00 +0000')); assert.format('%U', '14', null, new Date('2017-04-02 00:00:00 +0000')); // Test dates crossing a DST boundary. var dstStart = +new Date('2016-10-30 02:50:00'); assert.format('%T', '02:50:00', '00:50:00', new Date(dstStart)) assert.format('%T', '02:00:00', '01:00:00', new Date(dstStart + 10 * 60 * 1000)) ok('Time zones (' + process.env.TZ + ')'); } else { assert(false, '(Current timezone has no tests: ' + (process.env.TZ || 'none') + ')'); } /// check all formats in GMT, most coverage assert.format('%A', 'Tuesday'); assert.format('%a', 'Tue'); assert.format('%B', 'June'); assert.format('%b', 'Jun'); assert.format('%C', '20'); assert.format('%D', '06/07/11'); assert.format('%d', '07'); assert.format('%-d', '7'); assert.format('%_d', ' 7'); assert.format('%0d', '07'); assert.format('%e', ' 7'); assert.format('%F', '2011-06-07'); assert.format('%H', null, '18'); assert.format('%h', 'Jun'); assert.format('%I', null, '06'); assert.format('%-I', null, '6'); assert.format('%_I', null, ' 6'); assert.format('%0I', null, '06'); assert.format('%j', null, '158'); assert.format('%k', null, '18'); assert.format('%L', '067'); assert.format('%l', null, ' 6'); assert.format('%-l', null, '6'); assert.format('%_l', null, ' 6'); assert.format('%0l', null, '06'); assert.format('%M', null, '51'); assert.format('%m', '06'); assert.format('%n', '\n'); assert.format('%o', '7th'); assert.format('%P', null, 'pm'); assert.format('%p', null, 'PM'); assert.format('%R', null, '18:51'); assert.format('%r', null, '06:51:45 PM'); assert.format('%S', '45'); assert.format('%s', '1307472705'); assert.format('%T', null, '18:51:45'); assert.format('%t', '\t'); assert.format('%U', '23'); assert.format('%U', '24', null, new Date(+Time + 5 * 86400000)); assert.format('%u', '2'); assert.format('%v', ' 7-Jun-2011'); assert.format('%W', '23'); assert.format('%W', '23', null, new Date(+Time + 5 * 86400000)); assert.format('%w', '2'); assert.format('%Y', '2011'); assert.format('%y', '11'); assert.format('%Z', null, 'GMT'); assert.format('%z', null, '+0000'); assert.format('%:z', null, '+00:00'); assert.format('%%', '%'); // literal percent sign assert.format('%g', '%g'); // unrecognized directive assert.format('%F %T', null, '1970-01-01 00:00:00', new Date(0)); assert.format('%U', null, '12', new Date('2017-03-25 00:00:00 +0000')); assert.format('%U', null, '13', new Date('2017-03-26 00:00:00 +0000')); assert.format('%U', null, '13', new Date('2017-03-27 00:00:00 +0000')); assert.format('%U', null, '14', new Date('2017-04-02 00:00:00 +0000')); ok('GMT'); /// locales var it_IT = { days: words('domenica lunedi martedi mercoledi giovedi venerdi sabato'), shortDays: words('dom lun mar mer gio ven sab'), months: words('gennaio febbraio marzo aprile maggio giugno luglio agosto settembre ottobre novembre dicembre'), shortMonths: words('gen feb mar apr mag giu lug ago set ott nov dic'), AM: 'it$AM', PM: 'it$PM', am: 'it$am', pm: 'it$pm', formats: { D: 'it$%m/%d/%y', F: 'it$%Y-%m-%d', R: 'it$%H:%M', T: 'it$%H:%M:%S', X: '%T', c: '%a %b %d %X %Y', r: 'it$%I:%M:%S %p', v: 'it$%e-%b-%Y', x: '%D' } }; var strftimeIT = strftime.localize(it_IT), strftimeITUTC = strftimeIT.utc(); assert.format_it = function(format, expected, expectedUTC) { if (expected) { assertFormat(Time, format, expected, 'strftime.localize(it_IT)', strftimeIT); } assertFormat(Time, format, expectedUTC || expected, 'strftime.localize(it_IT).utc()', strftimeITUTC); }; assert.format_it('%A', 'martedi'); assert.format_it('%a', 'mar'); assert.format_it('%B', 'giugno'); assert.format_it('%b', 'giu'); assert.format_it('%c', null, 'mar giu 07 it$18:51:45 2011'); assert.format_it('%D', 'it$06/07/11'); assert.format_it('%F', 'it$2011-06-07'); assert.format_it('%p', null, 'it$PM'); assert.format_it('%P', null, 'it$pm'); assert.format_it('%R', null, 'it$18:51'); assert.format_it('%r', null, 'it$06:51:45 it$PM'); assert.format_it('%T', null, 'it$18:51:45'); assert.format_it('%v', 'it$ 7-giu-2011'); assert.format_it('%x', null, 'it$06/07/11'); assert.format_it('%X', null, 'it$18:51:45'); ok('Localization'); /// timezones assert.formatTZ = function(format, expected, tz, time) { assertFormat(time || Time, format, expected, 'strftime.timezone(' + tz + ')', strftime.timezone(tz)); }; assert.formatTZ('%F %r %z', '2011-06-07 06:51:45 PM +0000', 0); assert.formatTZ('%F %r %z', '2011-06-07 06:51:45 PM +0000', '+0000'); assert.formatTZ('%F %r %z', '2011-06-07 08:51:45 PM +0200', 120); assert.formatTZ('%F %r %z', '2011-06-07 08:51:45 PM +0200', '+0200'); assert.formatTZ('%F %r %z', '2011-06-07 11:51:45 AM -0700', -420); assert.formatTZ('%F %r %z', '2011-06-07 11:51:45 AM -0700', '-0700'); assert.formatTZ('%F %r %z', '2011-06-07 11:21:45 AM -0730', '-0730'); assert.formatTZ('%F %r %:z', '2011-06-07 11:21:45 AM -07:30', '-0730'); ok('Time zone offset'); /// caching (function() { // this test fails when the 2 calls cross a millisecond boundary, so try a number of times var CacheAttempts = 10; var MaxFailures = 1; var failures = 0; for (var i = 0; i < CacheAttempts; ++i) { var expectedMillis = strftime('%L'); var millis = strftime('%L'); if (expectedMillis != millis) { ++failures; } } if (failures > MaxFailures) { assert.fail('timestamp caching appears to be broken (' + failures + ' failed attempts out of ' + CacheAttempts + ')'); } }()); ok('Cached timestamps'); /// helpers function words(s) { return (s || '').split(' '); } function ok(s) { console.log('[ \033[32mOK\033[0m ] ' + s); } // Pass a regex or string that matches the timezone abbrev, e.g. %Z above. // Don't pass GMT! Every date includes it and it will fail. // Be careful if you pass a regex, it has to quack like the default one. function testTimezone(regex) { regex = typeof regex === 'string' ? RegExp('\\((' + regex + ')\\)$') : regex; var match = Time.toString().match(regex); if (match) { var off = Time.getTimezoneOffset(), hourOff = off / 60, hourDiff = Math.floor(hourOff), hours = 18 - hourDiff, padSpace24 = hours < 10 ? ' ' : '', padZero24 = hours < 10 ? '0' : '', hour24 = String(hours), padSpace12 = (hours % 12) < 10 ? ' ' : '', padZero12 = (hours % 12) < 10 ? '0' : '', hour12 = String(hours % 12), sign = hourDiff < 0 ? '+' : '-', minDiff = Time.getTimezoneOffset() - (hourDiff * 60), mins = String(51 - minDiff), tz = match[1], ampm = hour12 == hour24 ? 'AM' : 'PM', R = hour24 + ':' + mins, r = padZero12 + hour12 + ':' + mins + ':45 ' + ampm, T = R + ':45'; assert.format('%H', padZero24 + hour24, '18'); assert.format('%I', padZero12 + hour12, '06'); assert.format('%k', padSpace24 + hour24, '18'); assert.format('%l', padSpace12 + hour12, ' 6'); assert.format('%M', mins); assert.format('%P', ampm.toLowerCase(), 'pm'); assert.format('%p', ampm, 'PM'); assert.format('%R', R, '18:51'); assert.format('%r', r, '06:51:45 PM'); assert.format('%T', T, '18:51:45'); assert.format('%Z', tz, 'GMT'); assert.format('%z', sign + '0' + Math.abs(hourDiff) + '00', '+0000'); assert.format('%:z', sign + '0' + Math.abs(hourDiff) + ':00', '+00:00'); } }