date-and-time 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,6 +14,7 @@ Nowadays, JS modules have become huge, complex, and have many dependencies. We t
14
14
  - Extensible. Plugin system support.
15
15
  - Multi language support.
16
16
  - Universal / Isomorphic. Works wherever.
17
+ - TypeScript support.
17
18
  - Older browser support. Even works on IE6. :)
18
19
 
19
20
  ## Install
@@ -24,19 +25,15 @@ npm i date-and-time
24
25
 
25
26
  ## Recent Changes
26
27
 
28
+ - 2.4.2
29
+ - Fixed an issue where the timezone plugin stopped working due to Node.js timezone update.
30
+
27
31
  - 2.4.1
28
32
  - Fixed the previous Jest support.
29
33
 
30
34
  - 2.4.0
31
35
  - Support for testing in Jest.
32
36
 
33
- - 2.3.1
34
- - Updated dev dependencies to resolve vulnerabilities.
35
-
36
- - 2.3.0
37
- - TypeScript support.
38
- - Fixed an issue where `parseTZ()` in timezone plugin could return `NaN` instead of `Invalid Date` if parsing failed.
39
-
40
37
  ## Usage
41
38
 
42
39
  - ES Modules:
@@ -276,7 +273,7 @@ If the function fails to parse, it will return `Invalid Date`. Notice that the `
276
273
  ```javascript
277
274
  const today = date.parse('Jam 1 2017', 'MMM D YYYY');
278
275
 
279
- if (isNaN(today)) {
276
+ if (isNaN(today.getTime())) {
280
277
  // Failure
281
278
  }
282
279
  ```
@@ -1,17 +1,4 @@
1
- /*
2
- date-and-time (c) KNOWLEDGECODE | MIT
3
- */
4
- 'use strict';(function(p,m){"object"===typeof exports&&"undefined"!==typeof module?module.exports=m():"function"===typeof define&&define.amd?define(m):(p="undefined"!==typeof globalThis?globalThis:p||self,p.date=m())})(this,function(){var p={},m={},r="en",t={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
5
- ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},w={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+a.getFullYear()},MMMM:function(a){return this.res.MMMM[a.getMonth()]},MMM:function(a){return this.res.MMM[a.getMonth()]},MM:function(a){return("0"+(a.getMonth()+1)).slice(-2)},M:function(a){return""+(a.getMonth()+1)},DD:function(a){return("0"+a.getDate()).slice(-2)},
6
- D:function(a){return""+a.getDate()},HH:function(a){return("0"+a.getHours()).slice(-2)},H:function(a){return""+a.getHours()},A:function(a){return this.res.A[11<a.getHours()|0]},hh:function(a){return("0"+(a.getHours()%12||12)).slice(-2)},h:function(a){return""+(a.getHours()%12||12)},mm:function(a){return("0"+a.getMinutes()).slice(-2)},m:function(a){return""+a.getMinutes()},ss:function(a){return("0"+a.getSeconds()).slice(-2)},s:function(a){return""+a.getSeconds()},SSS:function(a){return("00"+a.getMilliseconds()).slice(-3)},
7
- SS:function(a){return("0"+(a.getMilliseconds()/10|0)).slice(-2)},S:function(a){return""+(a.getMilliseconds()/100|0)},dddd:function(a){return this.res.dddd[a.getDay()]},ddd:function(a){return this.res.ddd[a.getDay()]},dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.getTimezoneOffset()/.6|0;return(0<a?"-":"+")+("000"+Math.abs(a-(a%100*.4|0))).slice(-4)},ZZ:function(a){a=a.getTimezoneOffset();var b=Math.abs(a);return(0<a?"-":"+")+("0"+(b/60|0)).slice(-2)+":"+("0"+b%60).slice(-2)},post:function(a){return a},
8
- res:t},x={YYYY:function(a){return this.exec(/^\d{4}/,a)},Y:function(a){return this.exec(/^\d{1,4}/,a)},MMMM:function(a){a=this.find(this.res.MMMM,a);a.value++;return a},MMM:function(a){a=this.find(this.res.MMM,a);a.value++;return a},MM:function(a){return this.exec(/^\d\d/,a)},M:function(a){return this.exec(/^\d\d?/,a)},DD:function(a){return this.exec(/^\d\d/,a)},D:function(a){return this.exec(/^\d\d?/,a)},HH:function(a){return this.exec(/^\d\d/,a)},H:function(a){return this.exec(/^\d\d?/,a)},A:function(a){return this.find(this.res.A,
9
- a)},hh:function(a){return this.exec(/^\d\d/,a)},h:function(a){return this.exec(/^\d\d?/,a)},mm:function(a){return this.exec(/^\d\d/,a)},m:function(a){return this.exec(/^\d\d?/,a)},ss:function(a){return this.exec(/^\d\d/,a)},s:function(a){return this.exec(/^\d\d?/,a)},SSS:function(a){return this.exec(/^\d{1,3}/,a)},SS:function(a){a=this.exec(/^\d\d?/,a);a.value*=10;return a},S:function(a){a=this.exec(/^\d/,a);a.value*=100;return a},Z:function(a){a=this.exec(/^[\+-]\d{2}[0-5]\d/,a);a.value=-60*(a.value/
10
- 100|0)-a.value%100;return a},ZZ:function(a){a=/^([\+-])(\d{2}):([0-5]\d)/.exec(a)||["","","",""];return{value:-(60*(a[1]+a[2]|0)+(a[1]+a[3]|0)),length:a[0].length}},h12:function(a,b){return(12===a?0:a)+12*b},exec:function(a,b){a=(a.exec(b)||[""])[0];return{value:a|0,length:a.length}},find:function(a,b){for(var d=-1,c=0,h=0,g=a.length,l;h<g;h++)l=a[h],!b.indexOf(l)&&l.length>c&&(d=h,c=l.length);return{value:d,length:c}},pre:function(a){return a},res:t},n=function(a,b,d,c){var h={},g;for(g in a)h[g]=
11
- a[g];for(g in b||{})!!d^!!h[g]||(h[g]=b[g]);c&&(h.res=c);return h},f={_formatter:w,_parser:x};f.compile=function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,d,c=[a];d=b.exec(a);)c[c.length]=d[0];return c};f.format=function(a,b,d){var c=this||e;b="string"===typeof b?c.compile(b):b;var h=a.getTimezoneOffset();a=c.addMinutes(a,d?h:0);c=c._formatter;var g="";a.getTimezoneOffset=function(){return d?0:h};for(var l=1,u=b.length,k;l<u;l++)k=b[l],g+=c[k]?c.post(c[k](a,b[0])):k.replace(/\[(.*)]/,
12
- "$1");return g};f.preparse=function(a,b){var d=this||e;b="string"===typeof b?d.compile(b):b;var c={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},h=/\[(.*)]/;d=d._parser;var g=0;a=d.pre(a);for(var l=1,u=b.length,k,q;l<u;l++)if(k=b[l],d[k]){q=d[k](a.slice(g),b[0]);if(!q.length)break;g+=q.length;c[q.token||k.charAt(0)]=q.value;c._match++}else if(k===a.charAt(g)||" "===k)g++;else if(h.test(k)&&!a.slice(g).indexOf(h.exec(k)[1]))g+=k.length-2;else{"..."===k&&(g=a.length);break}c.H=
13
- c.H||d.h12(c.h,c.A);c._index=g;c._length=a.length;return c};f.parse=function(a,b,d){var c=this||e;b="string"===typeof b?c.compile(b):b;a=c.preparse(a,b);return c.isValid(a)?(a.M-=100>a.Y?22801:1,d||~c._parser.find(b,"ZZ").value?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};f.isValid=function(a,b){var d=this||e;a="string"===typeof a?d.preparse(a,b):a;d=[31,28+d.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1>
14
- a._length||a._index-a._length||1>a._match||1>a.Y||9999<a.Y||1>a.M||12<a.M||1>a.D||a.D>d||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-840>a.Z||720<a.Z)};f.transform=function(a,b,d,c){let h=this||e;return h.format(h.parse(a,b),d,c)};f.addYears=function(a,b){return(this||e).addMonths(a,12*b)};f.addMonths=function(a,b){a=new Date(a.getTime());a.setMonth(a.getMonth()+b);return a};f.addDays=function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a};f.addHours=function(a,
15
- b){return(this||e).addMinutes(a,60*b)};f.addMinutes=function(a,b){return(this||e).addSeconds(a,60*b)};f.addSeconds=function(a,b){return(this||e).addMilliseconds(a,1E3*b)};f.addMilliseconds=function(a,b){return new Date(a.getTime()+b)};f.subtract=function(a,b){var d=a.getTime()-b.getTime();return{toMilliseconds:function(){return d},toSeconds:function(){return d/1E3},toMinutes:function(){return d/6E4},toHours:function(){return d/36E5},toDays:function(){return d/864E5}}};f.isLeapYear=function(a){return!(a%
16
- 4)&&!!(a%100)||!(a%400)};f.isSameDay=function(a,b){return a.toDateString()===b.toDateString()};f.locale=function(a,b){p[a]||(p[a]=b)};f.plugin=function(a,b){m[a]||(m[a]=b)};var v=n(f);var e=n(f);e.locale=function(a){a="function"===typeof a?a:e.locale[a];if(!a)return r;r=a(f);var b=p[r]||{},d=n(t,b.res,!0);a=n(w,b.formatter,!0,d);b=n(x,b.parser,!0,d);e._formatter=v._formatter=a;e._parser=v._parser=b;for(var c in m)e.extend(m[c]);return r};e.extend=function(a){var b=n(e._parser.res,a.res),d=a.extender||
17
- {};e._formatter=n(e._formatter,a.formatter,!1,b);e._parser=n(e._parser,a.parser,!1,b);for(var c in d)e[c]||(e[c]=d[c])};e.plugin=function(a){(a="function"===typeof a?a:e.plugin[a])&&e.extend(m[a(f,v)]||{})};return e})
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).date=t()}(this,(function(){"use strict";
2
+ /**
3
+ * @preserve date-and-time (c) KNOWLEDGECODE | MIT
4
+ */var e,t,n={},r={},i="en",u={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"]},o={YYYY:function(e){return("000"+e.getFullYear()).slice(-4)},YY:function(e){return("0"+e.getFullYear()).slice(-2)},Y:function(e){return""+e.getFullYear()},MMMM:function(e){return this.res.MMMM[e.getMonth()]},MMM:function(e){return this.res.MMM[e.getMonth()]},MM:function(e){return("0"+(e.getMonth()+1)).slice(-2)},M:function(e){return""+(e.getMonth()+1)},DD:function(e){return("0"+e.getDate()).slice(-2)},D:function(e){return""+e.getDate()},HH:function(e){return("0"+e.getHours()).slice(-2)},H:function(e){return""+e.getHours()},A:function(e){return this.res.A[e.getHours()>11|0]},hh:function(e){return("0"+(e.getHours()%12||12)).slice(-2)},h:function(e){return""+(e.getHours()%12||12)},mm:function(e){return("0"+e.getMinutes()).slice(-2)},m:function(e){return""+e.getMinutes()},ss:function(e){return("0"+e.getSeconds()).slice(-2)},s:function(e){return""+e.getSeconds()},SSS:function(e){return("00"+e.getMilliseconds()).slice(-3)},SS:function(e){return("0"+(e.getMilliseconds()/10|0)).slice(-2)},S:function(e){return""+(e.getMilliseconds()/100|0)},dddd:function(e){return this.res.dddd[e.getDay()]},ddd:function(e){return this.res.ddd[e.getDay()]},dd:function(e){return this.res.dd[e.getDay()]},Z:function(e){var t=e.getTimezoneOffset()/.6|0;return(t>0?"-":"+")+("000"+Math.abs(t-(t%100*.4|0))).slice(-4)},ZZ:function(e){var t=e.getTimezoneOffset(),n=Math.abs(t);return(t>0?"-":"+")+("0"+(n/60|0)).slice(-2)+":"+("0"+n%60).slice(-2)},post:function(e){return e},res:u},s={YYYY:function(e){return this.exec(/^\d{4}/,e)},Y:function(e){return this.exec(/^\d{1,4}/,e)},MMMM:function(e){var t=this.find(this.res.MMMM,e);return t.value++,t},MMM:function(e){var t=this.find(this.res.MMM,e);return t.value++,t},MM:function(e){return this.exec(/^\d\d/,e)},M:function(e){return this.exec(/^\d\d?/,e)},DD:function(e){return this.exec(/^\d\d/,e)},D:function(e){return this.exec(/^\d\d?/,e)},HH:function(e){return this.exec(/^\d\d/,e)},H:function(e){return this.exec(/^\d\d?/,e)},A:function(e){return this.find(this.res.A,e)},hh:function(e){return this.exec(/^\d\d/,e)},h:function(e){return this.exec(/^\d\d?/,e)},mm:function(e){return this.exec(/^\d\d/,e)},m:function(e){return this.exec(/^\d\d?/,e)},ss:function(e){return this.exec(/^\d\d/,e)},s:function(e){return this.exec(/^\d\d?/,e)},SSS:function(e){return this.exec(/^\d{1,3}/,e)},SS:function(e){var t=this.exec(/^\d\d?/,e);return t.value*=10,t},S:function(e){var t=this.exec(/^\d/,e);return t.value*=100,t},Z:function(e){var t=this.exec(/^[\+-]\d{2}[0-5]\d/,e);return t.value=-60*(t.value/100|0)-t.value%100,t},ZZ:function(e){var t=/^([\+-])(\d{2}):([0-5]\d)/.exec(e)||["","","",""];return{value:0-(60*(t[1]+t[2]|0)+(t[1]+t[3]|0)),length:t[0].length}},h12:function(e,t){return(12===e?0:e)+12*t},exec:function(e,t){var n=(e.exec(t)||[""])[0];return{value:0|n,length:n.length}},find:function(e,t){for(var n,r=-1,i=0,u=0,o=e.length;u<o;u++)n=e[u],!t.indexOf(n)&&n.length>i&&(r=u,i=n.length);return{value:r,length:i}},pre:function(e){return e},res:u},c=function(e,t,n,r){var i,u={};for(i in e)u[i]=e[i];for(i in t||{})!!n^!!u[i]||(u[i]=t[i]);return r&&(u.res=r),u},a={_formatter:o,_parser:s};return a.compile=function(e){for(var t,n=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,r=[e];t=n.exec(e);)r[r.length]=t[0];return r},a.format=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,o=e.getTimezoneOffset(),s=i.addMinutes(e,r?o:0),c=i._formatter,a="";s.getTimezoneOffset=function(){return r?0:o};for(var f,d=1,l=u.length;d<l;d++)a+=c[f=u[d]]?c.post(c[f](s,u[0])):f.replace(/\[(.*)]/,"$1");return a},a.preparse=function(e,n){var r=this||t,i="string"==typeof n?r.compile(n):n,u={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},o=/\[(.*)]/,s=r._parser,c=0;e=s.pre(e);for(var a,f,d=1,l=i.length;d<l;d++)if(s[a=i[d]]){if(!(f=s[a](e.slice(c),i[0])).length)break;c+=f.length,u[f.token||a.charAt(0)]=f.value,u._match++}else if(a===e.charAt(c)||" "===a)c++;else{if(!o.test(a)||e.slice(c).indexOf(o.exec(a)[1])){if("..."===a){c=e.length;break}break}c+=a.length-2}return u.H=u.H||s.h12(u.h,u.A),u._index=c,u._length=e.length,u},a.parse=function(e,n,r){var i=this||t,u="string"==typeof n?i.compile(n):n,o=i.preparse(e,u);return i.isValid(o)?(o.M-=o.Y<100?22801:1,r||~i._parser.find(u,"ZZ").value?new Date(Date.UTC(o.Y,o.M,o.D,o.H,o.m+o.Z,o.s,o.S)):new Date(o.Y,o.M,o.D,o.H,o.m,o.s,o.S)):new Date(NaN)},a.isValid=function(e,n){var r=this||t,i="string"==typeof e?r.preparse(e,n):e,u=[31,28+r.isLeapYear(i.Y)|0,31,30,31,30,31,31,30,31,30,31][i.M-1];return!(i._index<1||i._length<1||i._index-i._length||i._match<1||i.Y<1||i.Y>9999||i.M<1||i.M>12||i.D<1||i.D>u||i.H<0||i.H>23||i.m<0||i.m>59||i.s<0||i.s>59||i.S<0||i.S>999||i.Z<-840||i.Z>720)},a.transform=function(e,n,r,i){const u=this||t;return u.format(u.parse(e,n),r,i)},a.addYears=function(e,n){return(this||t).addMonths(e,12*n)},a.addMonths=function(e,t){var n=new Date(e.getTime());return n.setMonth(n.getMonth()+t),n},a.addDays=function(e,t){var n=new Date(e.getTime());return n.setDate(n.getDate()+t),n},a.addHours=function(e,n){return(this||t).addMinutes(e,60*n)},a.addMinutes=function(e,n){return(this||t).addSeconds(e,60*n)},a.addSeconds=function(e,n){return(this||t).addMilliseconds(e,1e3*n)},a.addMilliseconds=function(e,t){return new Date(e.getTime()+t)},a.subtract=function(e,t){var n=e.getTime()-t.getTime();return{toMilliseconds:function(){return n},toSeconds:function(){return n/1e3},toMinutes:function(){return n/6e4},toHours:function(){return n/36e5},toDays:function(){return n/864e5}}},a.isLeapYear=function(e){return!((e%4||!(e%100))&&e%400)},a.isSameDay=function(e,t){return e.toDateString()===t.toDateString()},a.locale=function(e,t){n[e]||(n[e]=t)},a.plugin=function(e,t){r[e]||(r[e]=t)},e=c(a),(t=c(a)).locale=function(f){var d="function"==typeof f?f:t.locale[f];if(!d)return i;i=d(a);var l=n[i]||{},h=c(u,l.res,!0),M=c(o,l.formatter,!0,h),g=c(s,l.parser,!0,h);for(var p in t._formatter=e._formatter=M,t._parser=e._parser=g,r)t.extend(r[p]);return i},t.extend=function(e){var n=c(t._parser.res,e.res),r=e.extender||{};for(var i in t._formatter=c(t._formatter,e.formatter,!1,n),t._parser=c(t._parser,e.parser,!1,n),r)t[i]||(t[i]=r[i])},t.plugin=function(n){var i="function"==typeof n?n:t.plugin[n];i&&t.extend(r[i(a,e)]||{})},t}));
@@ -1,18 +1,4 @@
1
- /*
2
- date-and-time (c) KNOWLEDGECODE | MIT
3
- */
4
- var e={},f={},m="en",n={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},q={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+
5
- a.getFullYear()},MMMM:function(a){return this.res.MMMM[a.getMonth()]},MMM:function(a){return this.res.MMM[a.getMonth()]},MM:function(a){return("0"+(a.getMonth()+1)).slice(-2)},M:function(a){return""+(a.getMonth()+1)},DD:function(a){return("0"+a.getDate()).slice(-2)},D:function(a){return""+a.getDate()},HH:function(a){return("0"+a.getHours()).slice(-2)},H:function(a){return""+a.getHours()},A:function(a){return this.res.A[11<a.getHours()|0]},hh:function(a){return("0"+(a.getHours()%12||12)).slice(-2)},
6
- h:function(a){return""+(a.getHours()%12||12)},mm:function(a){return("0"+a.getMinutes()).slice(-2)},m:function(a){return""+a.getMinutes()},ss:function(a){return("0"+a.getSeconds()).slice(-2)},s:function(a){return""+a.getSeconds()},SSS:function(a){return("00"+a.getMilliseconds()).slice(-3)},SS:function(a){return("0"+(a.getMilliseconds()/10|0)).slice(-2)},S:function(a){return""+(a.getMilliseconds()/100|0)},dddd:function(a){return this.res.dddd[a.getDay()]},ddd:function(a){return this.res.ddd[a.getDay()]},
7
- dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.getTimezoneOffset()/.6|0;return(0<a?"-":"+")+("000"+Math.abs(a-(a%100*.4|0))).slice(-4)},ZZ:function(a){a=a.getTimezoneOffset();var b=Math.abs(a);return(0<a?"-":"+")+("0"+(b/60|0)).slice(-2)+":"+("0"+b%60).slice(-2)},post:function(a){return a},res:n},r={YYYY:function(a){return this.exec(/^\d{4}/,a)},Y:function(a){return this.exec(/^\d{1,4}/,a)},MMMM:function(a){a=this.find(this.res.MMMM,a);a.value++;return a},MMM:function(a){a=this.find(this.res.MMM,
8
- a);a.value++;return a},MM:function(a){return this.exec(/^\d\d/,a)},M:function(a){return this.exec(/^\d\d?/,a)},DD:function(a){return this.exec(/^\d\d/,a)},D:function(a){return this.exec(/^\d\d?/,a)},HH:function(a){return this.exec(/^\d\d/,a)},H:function(a){return this.exec(/^\d\d?/,a)},A:function(a){return this.find(this.res.A,a)},hh:function(a){return this.exec(/^\d\d/,a)},h:function(a){return this.exec(/^\d\d?/,a)},mm:function(a){return this.exec(/^\d\d/,a)},m:function(a){return this.exec(/^\d\d?/,
9
- a)},ss:function(a){return this.exec(/^\d\d/,a)},s:function(a){return this.exec(/^\d\d?/,a)},SSS:function(a){return this.exec(/^\d{1,3}/,a)},SS:function(a){a=this.exec(/^\d\d?/,a);a.value*=10;return a},S:function(a){a=this.exec(/^\d/,a);a.value*=100;return a},Z:function(a){a=this.exec(/^[\+-]\d{2}[0-5]\d/,a);a.value=-60*(a.value/100|0)-a.value%100;return a},ZZ:function(a){a=/^([\+-])(\d{2}):([0-5]\d)/.exec(a)||["","","",""];return{value:-(60*(a[1]+a[2]|0)+(a[1]+a[3]|0)),length:a[0].length}},h12:function(a,
10
- b){return(12===a?0:a)+12*b},exec:function(a,b){a=(a.exec(b)||[""])[0];return{value:a|0,length:a.length}},find:function(a,b){for(var d=-1,c=0,h=0,g=a.length,l;h<g;h++)l=a[h],!b.indexOf(l)&&l.length>c&&(d=h,c=l.length);return{value:d,length:c}},pre:function(a){return a},res:n};function t(a,b,d,c){var h={},g;for(g in a)h[g]=a[g];for(g in b||{})!!d^!!h[g]||(h[g]=b[g]);c&&(h.res=c);return h}var u={_formatter:q,_parser:r},w,x;
11
- u.compile=function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,d,c=[a];d=b.exec(a);)c[c.length]=d[0];return c};u.format=function(a,b,d){var c=this||x;b="string"===typeof b?c.compile(b):b;var h=a.getTimezoneOffset();a=c.addMinutes(a,d?h:0);c=c._formatter;var g="";a.getTimezoneOffset=function(){return d?0:h};for(var l=1,v=b.length,k;l<v;l++)k=b[l],g+=c[k]?c.post(c[k](a,b[0])):k.replace(/\[(.*)]/,"$1");return g};
12
- u.preparse=function(a,b){var d=this||x;b="string"===typeof b?d.compile(b):b;var c={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},h=/\[(.*)]/;d=d._parser;var g=0;a=d.pre(a);for(var l=1,v=b.length,k,p;l<v;l++)if(k=b[l],d[k]){p=d[k](a.slice(g),b[0]);if(!p.length)break;g+=p.length;c[p.token||k.charAt(0)]=p.value;c._match++}else if(k===a.charAt(g)||" "===k)g++;else if(h.test(k)&&!a.slice(g).indexOf(h.exec(k)[1]))g+=k.length-2;else{"..."===k&&(g=a.length);break}c.H=c.H||d.h12(c.h,
13
- c.A);c._index=g;c._length=a.length;return c};u.parse=function(a,b,d){var c=this||x;b="string"===typeof b?c.compile(b):b;a=c.preparse(a,b);return c.isValid(a)?(a.M-=100>a.Y?22801:1,d||~c._parser.find(b,"ZZ").value?new Date(Date.UTC(a.Y,a.M,a.D,a.H,a.m+a.Z,a.s,a.S)):new Date(a.Y,a.M,a.D,a.H,a.m,a.s,a.S)):new Date(NaN)};
14
- u.isValid=function(a,b){var d=this||x;a="string"===typeof a?d.preparse(a,b):a;d=[31,28+d.isLeapYear(a.Y)|0,31,30,31,30,31,31,30,31,30,31][a.M-1];return!(1>a._index||1>a._length||a._index-a._length||1>a._match||1>a.Y||9999<a.Y||1>a.M||12<a.M||1>a.D||a.D>d||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-840>a.Z||720<a.Z)};u.transform=function(a,b,d,c){let h=this||x;return h.format(h.parse(a,b),d,c)};u.addYears=function(a,b){return(this||x).addMonths(a,12*b)};
15
- u.addMonths=function(a,b){a=new Date(a.getTime());a.setMonth(a.getMonth()+b);return a};u.addDays=function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a};u.addHours=function(a,b){return(this||x).addMinutes(a,60*b)};u.addMinutes=function(a,b){return(this||x).addSeconds(a,60*b)};u.addSeconds=function(a,b){return(this||x).addMilliseconds(a,1E3*b)};u.addMilliseconds=function(a,b){return new Date(a.getTime()+b)};
16
- u.subtract=function(a,b){var d=a.getTime()-b.getTime();return{toMilliseconds:function(){return d},toSeconds:function(){return d/1E3},toMinutes:function(){return d/6E4},toHours:function(){return d/36E5},toDays:function(){return d/864E5}}};u.isLeapYear=function(a){return!(a%4)&&!!(a%100)||!(a%400)};u.isSameDay=function(a,b){return a.toDateString()===b.toDateString()};u.locale=function(a,b){e[a]||(e[a]=b)};u.plugin=function(a,b){f[a]||(f[a]=b)};w=t(u);x=t(u);
17
- x.locale=function(a){a="function"===typeof a?a:x.locale[a];if(!a)return m;m=a(u);var b=e[m]||{},d=t(n,b.res,!0);a=t(q,b.formatter,!0,d);b=t(r,b.parser,!0,d);x._formatter=w._formatter=a;x._parser=w._parser=b;for(var c in f)x.extend(f[c]);return m};x.extend=function(a){var b=t(x._parser.res,a.res),d=a.extender||{};x._formatter=t(x._formatter,a.formatter,!1,b);x._parser=t(x._parser,a.parser,!1,b);for(var c in d)x[c]||(x[c]=d[c])};
18
- x.plugin=function(a){(a="function"===typeof a?a:x.plugin[a])&&x.extend(f[a(u,w)]||{})};export default x
1
+ /**
2
+ * @preserve date-and-time (c) KNOWLEDGECODE | MIT
3
+ */
4
+ var e,t,n={},r={},u="en",i={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"]},o={YYYY:function(e){return("000"+e.getFullYear()).slice(-4)},YY:function(e){return("0"+e.getFullYear()).slice(-2)},Y:function(e){return""+e.getFullYear()},MMMM:function(e){return this.res.MMMM[e.getMonth()]},MMM:function(e){return this.res.MMM[e.getMonth()]},MM:function(e){return("0"+(e.getMonth()+1)).slice(-2)},M:function(e){return""+(e.getMonth()+1)},DD:function(e){return("0"+e.getDate()).slice(-2)},D:function(e){return""+e.getDate()},HH:function(e){return("0"+e.getHours()).slice(-2)},H:function(e){return""+e.getHours()},A:function(e){return this.res.A[e.getHours()>11|0]},hh:function(e){return("0"+(e.getHours()%12||12)).slice(-2)},h:function(e){return""+(e.getHours()%12||12)},mm:function(e){return("0"+e.getMinutes()).slice(-2)},m:function(e){return""+e.getMinutes()},ss:function(e){return("0"+e.getSeconds()).slice(-2)},s:function(e){return""+e.getSeconds()},SSS:function(e){return("00"+e.getMilliseconds()).slice(-3)},SS:function(e){return("0"+(e.getMilliseconds()/10|0)).slice(-2)},S:function(e){return""+(e.getMilliseconds()/100|0)},dddd:function(e){return this.res.dddd[e.getDay()]},ddd:function(e){return this.res.ddd[e.getDay()]},dd:function(e){return this.res.dd[e.getDay()]},Z:function(e){var t=e.getTimezoneOffset()/.6|0;return(t>0?"-":"+")+("000"+Math.abs(t-(t%100*.4|0))).slice(-4)},ZZ:function(e){var t=e.getTimezoneOffset(),n=Math.abs(t);return(t>0?"-":"+")+("0"+(n/60|0)).slice(-2)+":"+("0"+n%60).slice(-2)},post:function(e){return e},res:i},s={YYYY:function(e){return this.exec(/^\d{4}/,e)},Y:function(e){return this.exec(/^\d{1,4}/,e)},MMMM:function(e){var t=this.find(this.res.MMMM,e);return t.value++,t},MMM:function(e){var t=this.find(this.res.MMM,e);return t.value++,t},MM:function(e){return this.exec(/^\d\d/,e)},M:function(e){return this.exec(/^\d\d?/,e)},DD:function(e){return this.exec(/^\d\d/,e)},D:function(e){return this.exec(/^\d\d?/,e)},HH:function(e){return this.exec(/^\d\d/,e)},H:function(e){return this.exec(/^\d\d?/,e)},A:function(e){return this.find(this.res.A,e)},hh:function(e){return this.exec(/^\d\d/,e)},h:function(e){return this.exec(/^\d\d?/,e)},mm:function(e){return this.exec(/^\d\d/,e)},m:function(e){return this.exec(/^\d\d?/,e)},ss:function(e){return this.exec(/^\d\d/,e)},s:function(e){return this.exec(/^\d\d?/,e)},SSS:function(e){return this.exec(/^\d{1,3}/,e)},SS:function(e){var t=this.exec(/^\d\d?/,e);return t.value*=10,t},S:function(e){var t=this.exec(/^\d/,e);return t.value*=100,t},Z:function(e){var t=this.exec(/^[\+-]\d{2}[0-5]\d/,e);return t.value=-60*(t.value/100|0)-t.value%100,t},ZZ:function(e){var t=/^([\+-])(\d{2}):([0-5]\d)/.exec(e)||["","","",""];return{value:0-(60*(t[1]+t[2]|0)+(t[1]+t[3]|0)),length:t[0].length}},h12:function(e,t){return(12===e?0:e)+12*t},exec:function(e,t){var n=(e.exec(t)||[""])[0];return{value:0|n,length:n.length}},find:function(e,t){for(var n,r=-1,u=0,i=0,o=e.length;i<o;i++)n=e[i],!t.indexOf(n)&&n.length>u&&(r=i,u=n.length);return{value:r,length:u}},pre:function(e){return e},res:i},c=function(e,t,n,r){var u,i={};for(u in e)i[u]=e[u];for(u in t||{})!!n^!!i[u]||(i[u]=t[u]);return r&&(i.res=r),i},a={_formatter:o,_parser:s};a.compile=function(e){for(var t,n=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,r=[e];t=n.exec(e);)r[r.length]=t[0];return r},a.format=function(e,n,r){var u=this||t,i="string"==typeof n?u.compile(n):n,o=e.getTimezoneOffset(),s=u.addMinutes(e,r?o:0),c=u._formatter,a="";s.getTimezoneOffset=function(){return r?0:o};for(var f,d=1,h=i.length;d<h;d++)a+=c[f=i[d]]?c.post(c[f](s,i[0])):f.replace(/\[(.*)]/,"$1");return a},a.preparse=function(e,n){var r=this||t,u="string"==typeof n?r.compile(n):n,i={Y:1970,M:1,D:1,H:0,A:0,h:0,m:0,s:0,S:0,Z:0,_index:0,_length:0,_match:0},o=/\[(.*)]/,s=r._parser,c=0;e=s.pre(e);for(var a,f,d=1,h=u.length;d<h;d++)if(s[a=u[d]]){if(!(f=s[a](e.slice(c),u[0])).length)break;c+=f.length,i[f.token||a.charAt(0)]=f.value,i._match++}else if(a===e.charAt(c)||" "===a)c++;else{if(!o.test(a)||e.slice(c).indexOf(o.exec(a)[1])){if("..."===a){c=e.length;break}break}c+=a.length-2}return i.H=i.H||s.h12(i.h,i.A),i._index=c,i._length=e.length,i},a.parse=function(e,n,r){var u=this||t,i="string"==typeof n?u.compile(n):n,o=u.preparse(e,i);return u.isValid(o)?(o.M-=o.Y<100?22801:1,r||~u._parser.find(i,"ZZ").value?new Date(Date.UTC(o.Y,o.M,o.D,o.H,o.m+o.Z,o.s,o.S)):new Date(o.Y,o.M,o.D,o.H,o.m,o.s,o.S)):new Date(NaN)},a.isValid=function(e,n){var r=this||t,u="string"==typeof e?r.preparse(e,n):e,i=[31,28+r.isLeapYear(u.Y)|0,31,30,31,30,31,31,30,31,30,31][u.M-1];return!(u._index<1||u._length<1||u._index-u._length||u._match<1||u.Y<1||u.Y>9999||u.M<1||u.M>12||u.D<1||u.D>i||u.H<0||u.H>23||u.m<0||u.m>59||u.s<0||u.s>59||u.S<0||u.S>999||u.Z<-840||u.Z>720)},a.transform=function(e,n,r,u){const i=this||t;return i.format(i.parse(e,n),r,u)},a.addYears=function(e,n){return(this||t).addMonths(e,12*n)},a.addMonths=function(e,t){var n=new Date(e.getTime());return n.setMonth(n.getMonth()+t),n},a.addDays=function(e,t){var n=new Date(e.getTime());return n.setDate(n.getDate()+t),n},a.addHours=function(e,n){return(this||t).addMinutes(e,60*n)},a.addMinutes=function(e,n){return(this||t).addSeconds(e,60*n)},a.addSeconds=function(e,n){return(this||t).addMilliseconds(e,1e3*n)},a.addMilliseconds=function(e,t){return new Date(e.getTime()+t)},a.subtract=function(e,t){var n=e.getTime()-t.getTime();return{toMilliseconds:function(){return n},toSeconds:function(){return n/1e3},toMinutes:function(){return n/6e4},toHours:function(){return n/36e5},toDays:function(){return n/864e5}}},a.isLeapYear=function(e){return!((e%4||!(e%100))&&e%400)},a.isSameDay=function(e,t){return e.toDateString()===t.toDateString()},a.locale=function(e,t){n[e]||(n[e]=t)},a.plugin=function(e,t){r[e]||(r[e]=t)},e=c(a),(t=c(a)).locale=function(f){var d="function"==typeof f?f:t.locale[f];if(!d)return u;u=d(a);var h=n[u]||{},l=c(i,h.res,!0),M=c(o,h.formatter,!0,l),g=c(s,h.parser,!0,l);for(var p in t._formatter=e._formatter=M,t._parser=e._parser=g,r)t.extend(r[p]);return u},t.extend=function(e){var n=c(t._parser.res,e.res),r=e.extender||{};for(var u in t._formatter=c(t._formatter,e.formatter,!1,n),t._parser=c(t._parser,e.parser,!1,n),r)t[u]||(t[u]=r[u])},t.plugin=function(n){var u="function"==typeof n?n:t.plugin[n];u&&t.extend(r[u(a,e)]||{})};var f=t;export{f as default};
@@ -44,7 +44,7 @@ var plugin = function (date, localized_date) {
44
44
  var dateString2 = date.format(localized_date.parse(dateString, pattern2), pattern);
45
45
 
46
46
  var comparer = function (d) {
47
- return dateString2 === dateTimeFormat.format(d);
47
+ return dateString2 === dateTimeFormat.format(d).replace(/[\u202f]/, ' ');
48
48
  };
49
49
 
50
50
  // Trying to adjust for daylight saving time.
@@ -44,7 +44,7 @@ var plugin = function (date, localized_date) {
44
44
  var dateString2 = date.format(localized_date.parse(dateString, pattern2), pattern);
45
45
 
46
46
  var comparer = function (d) {
47
- return dateString2 === dateTimeFormat.format(d);
47
+ return dateString2 === dateTimeFormat.format(d).replace(/[\u202f]/, ' ');
48
48
  };
49
49
 
50
50
  // Trying to adjust for daylight saving time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-and-time",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "A Minimalist DateTime utility for Node.js and the browser",
5
5
  "main": "date-and-time.js",
6
6
  "module": "esm/date-and-time.es.js",
@@ -24,7 +24,7 @@
24
24
  }
25
25
  },
26
26
  "scripts": {
27
- "build": "rollup --config rollup.config.js",
27
+ "build": "rollup -c",
28
28
  "test": "./test.sh",
29
29
  "test:ts": "tsd ./test/ts"
30
30
  },
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "homepage": "https://github.com/knowledgecode/date-and-time",
48
48
  "devDependencies": {
49
- "@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
49
+ "@rollup/plugin-terser": "^0.3.0",
50
50
  "expect.js": "^0.3.1",
51
51
  "mocha": "^10.0.0",
52
52
  "mocha-headless-chrome": "^4.0.0",
@@ -50,7 +50,7 @@
50
50
  var dateString2 = date.format(localized_date.parse(dateString, pattern2), pattern);
51
51
 
52
52
  var comparer = function (d) {
53
- return dateString2 === dateTimeFormat.format(d);
53
+ return dateString2 === dateTimeFormat.format(d).replace(/[\u202f]/, ' ');
54
54
  };
55
55
 
56
56
  // Trying to adjust for daylight saving time.