Comparing version 0.9.2 to 0.10.0
{ | ||
"name": "strftime", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"main": "strftime.js", | ||
@@ -5,0 +5,0 @@ "ignore": [ |
@@ -0,1 +1,27 @@ | ||
v0.10.0 on 2016-12-28 | ||
--------------------- | ||
- Remove the old API deprecated in v0.9. | ||
- Bundle some locales that you can use with `strftime.localizedByIdentifier('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 | ||
@@ -2,0 +28,0 @@ -------------------- |
@@ -6,5 +6,5 @@ { | ||
"keywords": ["strftime", "format", "date", "time"], | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"main": "strftime.js", | ||
"scripts": ["strftime.js"] | ||
} |
{ | ||
"name": "strftime", | ||
"description": "strftime for JavaScript", | ||
"version": "0.9.2", | ||
"version": "0.10.0", | ||
"homepage": "http://samhuri.net/proj/strftime", | ||
"author": "Sami Samhuri <sami@samhuri.net>", | ||
"contributors": [ | ||
"Sami Samhuri <sami@samhuri.net> (http://samhuri.net)", | ||
"Andrew Schaaf <andrew@andrewschaaf.com> (http://andrewschaaf.com/)", | ||
"Rob Colburn <rob@robcolburn.com> (http://robcolburn.com/)", | ||
"Ryan Stafford (http://droffats.net/)", | ||
"Alexandr Nikitin <nikitin.alexandr.a@gmail.com>", | ||
"TJ Holowaychuk (http://tjholowaychuk.com/)", | ||
"Alexandr Nikitin (https://github.com/alexandrnikitin)", | ||
"Andrew Pirondini of iFixit (https://github.com/andrewjpiro)", | ||
"Andrew Schaaf <andrew@andrewschaaf.com> (https://github.com/andrewschaaf)", | ||
"Ayman Nedjmeddine (https://github.com/IOAyman)", | ||
"Cory Heslip (https://github.com/cheslip)", | ||
"Forbes Lindesay (https://github.com/ForbesLindesay)", | ||
"John Zwinck (https://github.com/jzwinck)", | ||
"Forbes Lindesay (https://github.com/ForbesLindesay)", | ||
"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 <rob@robcolburn.com> (https://github.com/robcolburn)", | ||
"Ryan Regalado (https://github.com/d48)", | ||
"Ryan Stafford (https://github.com/ryanstafford)", | ||
"Sami Samhuri <sami@samhuri.net> (https://github.com/samsonjs)", | ||
"Stian Grytøyr (https://github.com/stiang)", | ||
"TJ Holowaychuk (https://github.com/tj)", | ||
"w0den (https://github.com/w0den)" | ||
@@ -18,0 +26,0 @@ ], |
@@ -6,2 +6,3 @@ strftime | ||
[![version 0.10.0 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) | ||
@@ -23,13 +24,8 @@ Installation | ||
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. | ||
[yarn](https://yarnpkg.com): | ||
The New API in 0.9 | ||
================== | ||
yarn add strftime | ||
The current version, 0.9, deprecates the older API that exported several functions: `strftimeTZ`, `strftimeUTC`, and `localizedStrftime`. In addition to this the exported function referenced itself as `require('strftime').strftime` or `window.strftime.strftime` for consistency with the other functions. *These functions are deprecated in 0.9 and will be removed in 1.0.* | ||
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. | ||
Now you only need the single object exported and you can create a specialized version of it using the functions `utc()`, `localize(locale)`, and `timezone(offset)`. You can no longer pass in a timezone or locale on each call to `strftime` which is a regression. If you need this let me know and we will add it back into the API. | ||
[More details are available in the changelog](https://github.com/samsonjs/strftime/blob/master/Changelog.md). | ||
Usage | ||
@@ -75,2 +71,13 @@ ===== | ||
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. | ||
@@ -92,3 +99,3 @@ | ||
var strftimeCEST = strftime.timezone('+0200') | ||
console.log(strftimePDT('', new Date(1307472705067))) // => June 07, 11 11:51:45 | ||
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 | ||
@@ -110,7 +117,7 @@ ``` | ||
- C: AD century (year / 100), padded to 2 digits | ||
- c: equivalent to `%a %b %d %X %Y` in en-US (based on locale) | ||
- D: equivalent to `%m/%d/%y` in en-US (based on locale) | ||
- 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) | ||
- F: equivalent to `%Y-%m-%d` in en_US (based on locale) | ||
- H: the hour (24-hour clock), padded to 2 digits (00-23) | ||
@@ -129,15 +136,15 @@ - h: the same as %b (abbreviated month name) | ||
- 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) | ||
- 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: 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) | ||
- 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 `%D` in en-US (based on locale) | ||
- x: equivalent to `%T` in en-US (based on locale) | ||
- X: equivalent to `%D` in en_US (based on locale) | ||
- x: equivalent to `%T` in en_US (based on locale) | ||
- Y: the year with the century | ||
@@ -154,16 +161,39 @@ - y: the year without the century (00-99) | ||
<a name="locales"></a> | ||
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 | ||
============ | ||
* [Rob Colburn](https://github.com/robcolburn) | ||
* [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) | ||
* [TJ Holowaychuk](https://github.com/tj) | ||
* [Forbes Lindesay](https://github.com/ForbesLindesay) | ||
* [Alexandr Nikitin](https://github.com/alexandrnikitin) | ||
* [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) | ||
* [Andrew Schaaf](https://github.com/andrewschaaf) | ||
* [Ryan Stafford](https://github.com/ryanstafford) | ||
* [Stian Grytøyr](https://github.com/stiang) | ||
* [TJ Holowaychuk](https://github.com/tj) | ||
* [w0den](https://github.com/w0den) | ||
* [John Zwinck](https://github.com/jzwinck) | ||
@@ -174,5 +204,5 @@ | ||
Copyright 2010 - 2015 Sami Samhuri sami@samhuri.net | ||
Copyright 2010 - 2016 Sami Samhuri sami@samhuri.net | ||
[MIT license](http://sjs.mit-license.org) | ||
[MIT license](https://sjs.mit-license.org) | ||
@@ -1,12 +0,23 @@ | ||
(function(){function k(b,a){s[b]||(typeof console!=="undefined"&&typeof console.warn=="function"&&console.warn("[WARNING] "+b+" is deprecated and will be removed in version 1.0. Instead, use `"+a+"`."),s[b]=!0)}function t(b){b.localize=i.localize.bind(i);b.timezone=i.timezone.bind(i);b.utc=i.utc.bind(i)}function r(b,a,e){a&&a.days&&(e=a,a=void 0);e&&k("`"+g+"(format, [date], [locale])`","var s = "+g+".localize(locale); s(format, [date])");return(e?i.localize(e):i)(b,a)}function u(b,a,e){e?k("`"+g+ | ||
".strftime(format, [date], [locale])`","var s = "+g+".localize(locale); s(format, [date])"):k("`"+g+".strftime(format, [date])`",g+"(format, [date])");return(e?i.localize(e):i)(b,a)}function p(b,a,e){function g(b,c,h,a){for(var d="",f=null,e=!1,i=b.length,j=!1,o=0;o<i;o++){var n=b.charCodeAt(o);if(e===!0)if(n===45)f="";else if(n===95)f=" ";else if(n===48)f="0";else if(n===58)j&&typeof console!=="undefined"&&typeof console.warn=="function"&&console.warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"), | ||
j=!0;else{switch(n){case 65:d+=h.days[c.getDay()];break;case 66:d+=h.months[c.getMonth()];break;case 67:d+=l(Math.floor(c.getFullYear()/100),f);break;case 68:d+=g(h.formats.D,c,h,a);break;case 70:d+=g(h.formats.F,c,h,a);break;case 72:d+=l(c.getHours(),f);break;case 73:d+=l(v(c.getHours()),f);break;case 76:d+=Math.floor(a%1E3)>99?Math.floor(a%1E3):Math.floor(a%1E3)>9?"0"+Math.floor(a%1E3):"00"+Math.floor(a%1E3);break;case 77:d+=l(c.getMinutes(),f);break;case 80:d+=c.getHours()<12?h.am:h.pm;break;case 82:d+= | ||
g(h.formats.R,c,h,a);break;case 83:d+=l(c.getSeconds(),f);break;case 84:d+=g(h.formats.T,c,h,a);break;case 85:d+=l(w(c,"sunday"),f);break;case 87:d+=l(w(c,"monday"),f);break;case 88:d+=g(h.formats.X,c,h,a);break;case 89:d+=c.getFullYear();break;case 90:k&&m===0?d+="GMT":(f=c.toString().match(/\(([\w\s]+)\)/),d+=f&&f[1]||"");break;case 97:d+=h.shortDays[c.getDay()];break;case 98:d+=h.shortMonths[c.getMonth()];break;case 99:d+=g(h.formats.c,c,h,a);break;case 100:d+=l(c.getDate(),f);break;case 101:d+= | ||
l(c.getDate(),f==null?" ":f);break;case 104:d+=h.shortMonths[c.getMonth()];break;case 106:f=new Date(c.getFullYear(),0,1);f=Math.ceil((c.getTime()-f.getTime())/864E5);d+=f>99?f:f>9?"0"+f:"00"+f;break;case 107:d+=l(c.getHours(),f==null?" ":f);break;case 108:d+=l(v(c.getHours()),f==null?" ":f);break;case 109:d+=l(c.getMonth()+1,f);break;case 110:d+="\n";break;case 111:d+=String(c.getDate())+A(c.getDate());break;case 112:d+=c.getHours()<12?h.AM:h.PM;break;case 114:d+=g(h.formats.r,c,h,a);break;case 115:d+= | ||
Math.floor(a/1E3);break;case 116:d+="\t";break;case 117:f=c.getDay();d+=f===0?7:f;break;case 118:d+=g(h.formats.v,c,h,a);break;case 119:d+=c.getDay();break;case 120:d+=g(h.formats.x,c,h,a);break;case 121:d+=(""+c.getFullYear()).slice(2);break;case 122:k&&m===0?d+=j?"+00:00":"+0000":(f=m!==0?m/6E4:-c.getTimezoneOffset(),e=j?":":"",n=Math.abs(f%60),d+=(f<0?"-":"+")+l(Math.floor(Math.abs(f/60)))+e+l(n));break;default:d+=b[o]}f=null;e=!1}else n===37?e=!0:d+=b[o]}return d}var i=b||x,m=a||0,k=e||!1,j=0, | ||
q,b=function(b,c){var a;c?(a=c.getTime(),k&&(c=new Date(c.getTime()+(c.getTimezoneOffset()||0)*6E4+m))):(a=Date.now(),a>j?(j=a,q=new Date(j),a=j,k&&(q=new Date(j+(q.getTimezoneOffset()||0)*6E4+m))):a=j,c=q);return g(b,c,i,a)};b.localize=function(a){return new p(a||i,m,k)};b.timezone=function(a){var c=m,b=k,e=typeof a;if(e==="number"||e==="string")b=!0,e==="string"?(c=a[0]==="-"?-1:1,e=parseInt(a.slice(1,3),10),a=parseInt(a.slice(3,5),10),c=c*(60*e+a)*6E4):e==="number"&&(c=a*6E4);return new p(i,c, | ||
b)};b.utc=function(){return new p(i,m,!0)};return b}function l(b,a){if(a===""||b>9)return b;a==null&&(a="0");return a+b}function v(b){if(b===0)return 12;else if(b>12)return b-12;return b}function w(b,a){var a=a||"sunday",e=b.getDay();a==="monday"&&(e===0?e=6:e--);var g=Date.UTC(b.getFullYear(),0,1),i=Date.UTC(b.getFullYear(),b.getMonth(),b.getDate());return Math.floor((Math.floor((i-g)/864E5)+7-e)/7)}function A(b){var a=b%10;b%=100;if(b>=11&&b<=13||a===0||a>=4)return"th";switch(a){case 1:return"st"; | ||
case 2:return"nd";case 3:return"rd"}}var x={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"],AM:"AM",PM:"PM",am:"am",pm:"pm",formats:{D:"%m/%d/%y",F:"%Y-%m-%d",R:"%H:%M",T:"%H:%M:%S",X:"%T",c:"%a %b %d %X %Y",r:"%I:%M:%S %p", | ||
v:"%e-%b-%Y",x:"%D"}},i=new p(x,0,!1),y=typeof module!=="undefined",j;y?(j=module.exports=r,j.strftime=u):(j=function(){return this||(0,eval)("this")}(),j.strftime=r);var g=y?"require('strftime')":"strftime",s={};j.strftimeTZ=function(b,a,e,j){if((typeof e=="number"||typeof e=="string")&&j==null)j=e,e=void 0;e?k("`"+g+".strftimeTZ(format, date, locale, tz)`","var s = "+g+".localize(locale).timezone(tz); s(format, [date])` or `var s = "+g+".localize(locale); s.timezone(tz)(format, [date])"):k("`"+ | ||
g+".strftimeTZ(format, date, tz)`","var s = "+g+".timezone(tz); s(format, [date])` or `"+g+".timezone(tz)(format, [date])");return(e?i.localize(e):i).timezone(j)(b,a)};j.strftimeUTC=function(b,a,e){e?k("`"+g+".strftimeUTC(format, date, locale)`","var s = "+g+".localize(locale).utc(); s(format, [date])"):k("`"+g+".strftimeUTC(format, [date])`","var s = "+g+".utc(); s(format, [date])");return(e?z.localize(e):z)(b,a)};j.localizedStrftime=function(b){k("`"+g+".localizedStrftime(locale)`",g+".localize(locale)"); | ||
return i.localize(b)};t(r);t(u);var z=i.utc();if(typeof Date.now!=="function")Date.now=function(){return+new Date}})(); | ||
(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;j<l;j++){var m=c.charCodeAt(j);if(g===!0)if(m===45)d="";else if(m===95)d=" ";else if(m===48)d="0";else if(m===58)n&&t("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"),n=!0;else{switch(m){case 37:b+="%";break;case 65:b+=e.days[a.getDay()];break;case 66:b+=e.months[a.getMonth()];break;case 67:b+=h(Math.floor(a.getFullYear()/100),d);break;case 68:b+=i(e.formats.D,a,e,f);break;case 70:b+= | ||
i(e.formats.F,a,e,f);break;case 72:b+=h(a.getHours(),d);break;case 73:b+=h(u(a.getHours()),d);break;case 76:b+=Math.floor(f%1E3)>99?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}})(); |
383
strftime.js
@@ -6,3 +6,3 @@ // | ||
// | ||
// Copyright 2010 - 2015 Sami Samhuri <sami@samhuri.net> | ||
// Copyright 2010 - 2016 Sami Samhuri <sami@samhuri.net> | ||
// | ||
@@ -15,7 +15,36 @@ // MIT License | ||
var DefaultLocale = { | ||
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], | ||
var Locales = { | ||
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: { | ||
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', | ||
@@ -26,13 +55,222 @@ 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é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', | ||
c: '%a %b %d %X %Y', | ||
x: '%D' | ||
} | ||
}, | ||
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: { | ||
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: ['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ç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: { | ||
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: { | ||
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<michaeljayt@gmail.com> | ||
// https://github.com/michaeljayt/strftime/commit/bcb4c12743811d51e568175aa7bff3fd2a77cef3 | ||
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), | ||
@@ -44,4 +282,3 @@ isCommonJS = typeof module !== 'undefined', | ||
if (isCommonJS) { | ||
namespace = module.exports = adaptedStrftime; | ||
namespace.strftime = deprecatedStrftime; | ||
namespace = module.exports = defaultStrftime; | ||
} | ||
@@ -52,90 +289,5 @@ // Browsers and other environments | ||
namespace = (function() { return this || (1,eval)('this'); }()); | ||
namespace.strftime = adaptedStrftime; | ||
namespace.strftime = defaultStrftime; | ||
} | ||
// Deprecated API, to be removed in v1.0 | ||
var _require = isCommonJS ? "require('strftime')" : "strftime"; | ||
var _deprecationWarnings = {}; | ||
function deprecationWarning(name, instead) { | ||
if (!_deprecationWarnings[name]) { | ||
if (typeof console !== 'undefined' && typeof console.warn == 'function') { | ||
console.warn("[WARNING] " + name + " is deprecated and will be removed in version 1.0. Instead, use `" + instead + "`."); | ||
} | ||
_deprecationWarnings[name] = true; | ||
} | ||
} | ||
namespace.strftimeTZ = deprecatedStrftimeTZ; | ||
namespace.strftimeUTC = deprecatedStrftimeUTC; | ||
namespace.localizedStrftime = deprecatedStrftimeLocalized; | ||
// Adapt the old API while preserving the new API. | ||
function adaptForwards(fn) { | ||
fn.localize = defaultStrftime.localize.bind(defaultStrftime); | ||
fn.timezone = defaultStrftime.timezone.bind(defaultStrftime); | ||
fn.utc = defaultStrftime.utc.bind(defaultStrftime); | ||
} | ||
adaptForwards(adaptedStrftime); | ||
function adaptedStrftime(fmt, d, locale) { | ||
// d and locale are optional, check if this is (format, locale) | ||
if (d && d.days) { | ||
locale = d; | ||
d = undefined; | ||
} | ||
if (locale) { | ||
deprecationWarning("`" + _require + "(format, [date], [locale])`", "var s = " + _require + ".localize(locale); s(format, [date])"); | ||
} | ||
var strftime = locale ? defaultStrftime.localize(locale) : defaultStrftime; | ||
return strftime(fmt, d); | ||
} | ||
adaptForwards(deprecatedStrftime); | ||
function deprecatedStrftime(fmt, d, locale) { | ||
if (locale) { | ||
deprecationWarning("`" + _require + ".strftime(format, [date], [locale])`", "var s = " + _require + ".localize(locale); s(format, [date])"); | ||
} | ||
else { | ||
deprecationWarning("`" + _require + ".strftime(format, [date])`", _require + "(format, [date])"); | ||
} | ||
var strftime = locale ? defaultStrftime.localize(locale) : defaultStrftime; | ||
return strftime(fmt, d); | ||
} | ||
function deprecatedStrftimeTZ(fmt, d, locale, timezone) { | ||
// locale is optional, check if this is (format, date, timezone) | ||
if ((typeof locale == 'number' || typeof locale == 'string') && timezone == null) { | ||
timezone = locale; | ||
locale = undefined; | ||
} | ||
if (locale) { | ||
deprecationWarning("`" + _require + ".strftimeTZ(format, date, locale, tz)`", "var s = " + _require + ".localize(locale).timezone(tz); s(format, [date])` or `var s = " + _require + ".localize(locale); s.timezone(tz)(format, [date])"); | ||
} | ||
else { | ||
deprecationWarning("`" + _require + ".strftimeTZ(format, date, tz)`", "var s = " + _require + ".timezone(tz); s(format, [date])` or `" + _require + ".timezone(tz)(format, [date])"); | ||
} | ||
var strftime = (locale ? defaultStrftime.localize(locale) : defaultStrftime).timezone(timezone); | ||
return strftime(fmt, d); | ||
} | ||
var utcStrftime = defaultStrftime.utc(); | ||
function deprecatedStrftimeUTC(fmt, d, locale) { | ||
if (locale) { | ||
deprecationWarning("`" + _require + ".strftimeUTC(format, date, locale)`", "var s = " + _require + ".localize(locale).utc(); s(format, [date])"); | ||
} | ||
else { | ||
deprecationWarning("`" + _require + ".strftimeUTC(format, [date])`", "var s = " + _require + ".utc(); s(format, [date])"); | ||
} | ||
var strftime = locale ? utcStrftime.localize(locale) : utcStrftime; | ||
return strftime(fmt, d); | ||
} | ||
function deprecatedStrftimeLocalized(locale) { | ||
deprecationWarning("`" + _require + ".localizedStrftime(locale)`", _require + ".localize(locale)"); | ||
return defaultStrftime.localize(locale); | ||
} | ||
// End of deprecated API | ||
// Polyfill Date.now for old browsers. | ||
@@ -186,3 +338,10 @@ if (typeof Date.now !== 'function') { | ||
if (_useUtcBasedDate) { | ||
date = new Date(date.getTime() + getTimestampToUtcOffsetFor(date) + _customTimezoneOffset); | ||
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); | ||
} | ||
} | ||
@@ -224,5 +383,3 @@ } | ||
if (extendedTZ) { | ||
if (typeof console !== 'undefined' && typeof console.warn == 'function') { | ||
console.warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"); | ||
} | ||
warn("[WARNING] detected use of unsupported %:: or %::: modifiers to strftime"); | ||
} | ||
@@ -237,2 +394,8 @@ extendedTZ = true; | ||
// '%' | ||
// case '%': | ||
case 37: | ||
resultString += '%'; | ||
break; | ||
// 'Thursday' | ||
@@ -424,3 +587,11 @@ // case 'A': | ||
case 111: | ||
resultString += String(date.getDate()) + ordinal(date.getDate()); | ||
// 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; | ||
@@ -506,2 +677,5 @@ | ||
default: | ||
if (isInScope) { | ||
resultString += '%'; | ||
} | ||
resultString += format[i]; | ||
@@ -534,2 +708,11 @@ break; | ||
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) { | ||
@@ -640,2 +823,8 @@ var customTimezoneOffset = _customTimezoneOffset; | ||
function warn(message) { | ||
if (typeof console !== 'undefined' && typeof console.warn == 'function') { | ||
console.warn(message) | ||
} | ||
} | ||
}()); |
38
test.js
@@ -30,9 +30,2 @@ #!/usr/bin/env node | ||
/// check deprecated exports | ||
assert.fn(strftime.strftime); | ||
assert.fn(strftime.strftimeTZ); | ||
assert.fn(strftime.strftimeUTC); | ||
assert.fn(strftime.localizedStrftime); | ||
ok('Deprecated exports'); | ||
/// check exports | ||
@@ -46,6 +39,6 @@ assert.fn(strftime.localize); | ||
if (process.env.TZ == 'America/Vancouver') { | ||
testTimezone('P[DS]T'); | ||
testTimezone('America/Vancouver'); | ||
assert.format('%C', '01', '01', new Date(100, 0, 1)); | ||
assert.format('%X', '11:51:45', '18:51:45'); | ||
assert.format('%c', 'Tue Jun 07 11:51:45 2011', 'Tue Jun 07 18:51:45 2011'); | ||
assert.format('%X', '11:51:45 AM', '06:51:45 PM'); | ||
assert.format('%c', 'Tue 07 Jun 2011 11:51:45 AM PDT', 'Tue 07 Jun 2011 06:51:45 PM GMT'); | ||
assert.format('%j', '097', '098', new Date(1365390736236)); | ||
@@ -57,9 +50,15 @@ assert.format('%x', '06/07/11'); | ||
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 == 'CET') { | ||
testTimezone('CES?T'); | ||
else if (process.env.TZ == 'Europe/Amsterdam') { | ||
testTimezone('Europe/Amsterdam'); | ||
assert.format('%C', '01', '00', new Date(100, 0, 1)); | ||
assert.format('%X', '20:51:45', '18:51:45'); | ||
assert.format('%c', 'Tue Jun 07 20:51:45 2011', 'Tue Jun 07 18:51:45 2011'); | ||
assert.format('%X', '08:51:45 PM', '06:51:45 PM'); | ||
assert.format('%c', 'Tue 07 Jun 2011 08:51:45 PM CEST', 'Tue 07 Jun 2011 06:51:45 PM GMT'); | ||
assert.format('%j', '098', '098', new Date(1365390736236)); | ||
@@ -71,6 +70,12 @@ assert.format('%x', '06/07/11'); | ||
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 { | ||
console.log('(Current timezone has no tests: ' + (process.env.TZ || 'none') + ')'); | ||
assert(false, '(Current timezone has no tests: ' + (process.env.TZ || 'none') + ')'); | ||
} | ||
@@ -128,3 +133,4 @@ | ||
assert.format('%:z', null, '+00:00'); | ||
assert.format('%%', '%'); // any other char | ||
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)); | ||
@@ -131,0 +137,0 @@ assert.format('%U', null, '12', new Date('2017-03-25 00:00:00 +0000')); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
73415
15
1068
201
147619