Socket
Socket
Sign inDemoInstall

date-and-time

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-and-time - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

esm/plugin/timezone.es.js

231

date-and-time.js

@@ -11,4 +11,3 @@ (function (global, factory) {

var date = {},
locales = {},
var locales = {},
plugins = {},

@@ -50,6 +49,7 @@ lang = 'en',

Z: function (d/*, formatString*/) {
var offset = d.utc ? 0 : d.getTimezoneOffset() / 0.6;
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - offset % 100 * 0.4)).slice(-4);
var offset = d.getTimezoneOffset() / 0.6 | 0;
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - (offset % 100 * 0.4 | 0))).slice(-4);
},
post: function (str) { return str; }
post: function (str) { return str; },
res: _res
},

@@ -115,29 +115,27 @@ _parser = {

},
pre: function (str) { return str; }
pre: function (str) { return str; },
res: _res
},
customize = function (code, base, locale) {
var extend = function (proto, props, res) {
var Locale = function (r) {
if (r) { this.res = r; }
};
extend = function (base, props, override, res) {
var obj = {}, key;
Locale.prototype = proto;
Locale.prototype.constructor = Locale;
for (key in base) {
obj[key] = base[key];
}
for (key in props || {}) {
if (!(!!override ^ !!obj[key])) {
obj[key] = props[key];
}
}
if (res) {
obj.res = res;
}
return obj;
};
var newLocale = new Locale(res),
value;
var proto = {
_formatter: _formatter,
_parser: _parser
};
for (var key in props || {}) {
value = props[key];
newLocale[key] = value.slice ? value.slice() : value;
}
return newLocale;
},
loc = { res: extend(base.res, locale.res) };
loc.formatter = extend(base.formatter, locale.formatter, loc.res);
loc.parser = extend(base.parser, locale.parser, loc.res);
locales[code] = loc;
};
/**

@@ -148,3 +146,3 @@ * Compiling a format string

*/
date.compile = function (formatString) {
proto.compile = function (formatString) {
var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];

@@ -165,8 +163,9 @@

*/
date.format = function (dateObj, arg, utc) {
var pattern = typeof arg === 'string' ? date.compile(arg) : arg,
d = date.addMinutes(dateObj, utc ? dateObj.getTimezoneOffset() : 0),
formatter = locales[lang].formatter, str = '';
proto.format = function (dateObj, arg, utc) {
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
offset = dateObj.getTimezoneOffset(),
d = this.addMinutes(dateObj, utc ? offset : 0),
formatter = this._formatter, str = '';
d.utc = utc || false;
d.getTimezoneOffset = function () { return utc ? 0 : offset; };
for (var i = 1, len = pattern.length, token; i < len; i++) {

@@ -185,6 +184,6 @@ token = pattern[i];

*/
date.preparse = function (dateString, arg) {
var pattern = typeof arg === 'string' ? date.compile(arg) : arg,
proto.preparse = function (dateString, arg) {
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
dt = { 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 },
comment = /\[(.*)]/, parser = locales[lang].parser, offset = 0;
comment = /\[(.*)]/, parser = this._parser, offset = 0;

@@ -200,3 +199,3 @@ dateString = parser.pre(dateString);

offset += result.length;
dt[token.charAt(0)] = result.value;
dt[result.token || token.charAt(0)] = result.value;
dt._match++;

@@ -221,20 +220,2 @@ } else if (token === dateString.charAt(offset) || token === ' ') {

/**
* Validation
* @param {Object|string} arg1 - a date structure or a date string
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
* @returns {boolean} whether the date string is a valid date
*/
date.isValid = function (arg1, arg2) {
var dt = typeof arg1 === 'string' ? date.preparse(arg1, arg2) : arg1,
last = [31, 28 + date.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
return !(
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
dt.Z < -720 || dt.Z > 840
);
};
/**
* Parsing a Date and Time string

@@ -246,6 +227,6 @@ * @param {string} dateString - a date string

*/
date.parse = function (dateString, arg, utc) {
var dt = date.preparse(dateString, arg);
proto.parse = function (dateString, arg, utc) {
var dt = this.preparse(dateString, arg);
if (date.isValid(dt)) {
if (this.isValid(dt)) {
dt.M -= dt.Y < 100 ? 22801 : 1; // 22801 = 1900 * 12 + 1

@@ -261,2 +242,20 @@ if (utc || dt.Z) {

/**
* Validation
* @param {Object|string} arg1 - a date structure or a date string
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
* @returns {boolean} whether the date string is a valid date
*/
proto.isValid = function (arg1, arg2) {
var dt = typeof arg1 === 'string' ? this.preparse(arg1, arg2) : arg1,
last = [31, 28 + this.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
return !(
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
dt.Z < -720 || dt.Z > 840
);
};
/**
* Transforming a Date and Time string

@@ -269,4 +268,4 @@ * @param {string} dateString - a date string

*/
date.transform = function (dateString, arg1, arg2, utc) {
return date.format(date.parse(dateString, arg1), arg2, utc);
proto.transform = function (dateString, arg1, arg2, utc) {
return this.format(this.parse(dateString, arg1), arg2, utc);
};

@@ -280,4 +279,4 @@

*/
date.addYears = function (dateObj, years) {
return date.addMonths(dateObj, years * 12);
proto.addYears = function (dateObj, years) {
return this.addMonths(dateObj, years * 12);
};

@@ -291,3 +290,3 @@

*/
date.addMonths = function (dateObj, months) {
proto.addMonths = function (dateObj, months) {
var d = new Date(dateObj.getTime());

@@ -305,3 +304,3 @@

*/
date.addDays = function (dateObj, days) {
proto.addDays = function (dateObj, days) {
var d = new Date(dateObj.getTime());

@@ -319,4 +318,4 @@

*/
date.addHours = function (dateObj, hours) {
return date.addMinutes(dateObj, hours * 60);
proto.addHours = function (dateObj, hours) {
return this.addMinutes(dateObj, hours * 60);
};

@@ -330,4 +329,4 @@

*/
date.addMinutes = function (dateObj, minutes) {
return date.addSeconds(dateObj, minutes * 60);
proto.addMinutes = function (dateObj, minutes) {
return this.addSeconds(dateObj, minutes * 60);
};

@@ -341,4 +340,4 @@

*/
date.addSeconds = function (dateObj, seconds) {
return date.addMilliseconds(dateObj, seconds * 1000);
proto.addSeconds = function (dateObj, seconds) {
return this.addMilliseconds(dateObj, seconds * 1000);
};

@@ -352,3 +351,3 @@

*/
date.addMilliseconds = function (dateObj, milliseconds) {
proto.addMilliseconds = function (dateObj, milliseconds) {
return new Date(dateObj.getTime() + milliseconds);

@@ -363,3 +362,3 @@ };

*/
date.subtract = function (date1, date2) {
proto.subtract = function (date1, date2) {
var delta = date1.getTime() - date2.getTime();

@@ -391,3 +390,3 @@

*/
date.isLeapYear = function (y) {
proto.isLeapYear = function (y) {
return (!(y % 4) && !!(y % 100)) || !(y % 400);

@@ -402,3 +401,3 @@ };

*/
date.isSameDay = function (date1, date2) {
proto.isSameDay = function (date1, date2) {
return date1.toDateString() === date2.toDateString();

@@ -408,13 +407,52 @@ };

/**
* Changing the locale or defining new locales
* @param {Function|string} [code] - locale installer | language code
* @param {Object} [locale] - locale definition
* Defining new locale
* @param {string} code - language code
* @param {Function} locale - locale installer
* @returns {string} current language code
*/
date.locale = function (code, locale) {
if (locale) {
customize(code, { res: _res, formatter: _formatter, parser: _parser }, locale);
} else {
lang = (typeof code === 'function' ? code : date.locale[code] || function () {})(date) || lang;
proto.locale = function (code, locale) {
if (!locales[code]) {
locales[code] = locale;
}
};
/**
* Defining new plugin
* @param {string} name - plugin name
* @param {Function} plugin - plugin installer
* @returns {void}
*/
proto.plugin = function (name, plugin) {
if (!plugins[name]) {
plugins[name] = plugin;
}
};
var date = extend(proto);
/**
* Changing locale
* @param {Function|string} [locale] - locale object | language code
* @returns {string} current language code
*/
date.locale = function (locale) {
var install = typeof locale === 'function' ? locale : date.locale[locale];
if (!install) {
return lang;
}
lang = install(proto);
var extension = locales[lang] || {};
var res = extend(_res, extension.res, true);
var formatter = extend(_formatter, extension.formatter, true, res);
var parser = extend(_parser, extension.parser, true, res);
date._formatter = formatter;
date._parser = parser;
for (var plugin in plugins) {
date.extend(plugins[plugin]);
}
return lang;

@@ -429,4 +467,8 @@ };

date.extend = function (extension) {
var res = extend(date._parser.res, extension.res);
var extender = extension.extender || {};
date._formatter = extend(date._formatter, extension.formatter, false, res);
date._parser = extend(date._parser, extension.parser, false, res);
for (var key in extender) {

@@ -437,28 +479,19 @@ if (!date[key]) {

}
if (extension.formatter || extension.parser || extension.res) {
customize(lang, locales[lang], extension);
}
};
/**
* Importing or defining plugins
* @param {Function|string} name - plugin installer | plugin name
* @param {Object} [plugin] - plugin object
* Importing plugin
* @param {Function|string} plugin - plugin object | plugin name
* @returns {void}
*/
date.plugin = function (name, plugin) {
if (plugin) {
if (!plugins[name]) {
date.extend((plugins[name] = plugin));
}
} else {
(typeof name === 'function' ? name : date.plugin[name] || function () {})(date);
date.plugin = function (plugin) {
var install = typeof plugin === 'function' ? plugin : date.plugin[plugin];
if (install) {
date.extend(plugins[install(proto)] || {});
}
};
// Create default locale (English)
date.locale(lang, {});
return date;
})));
/*
date-and-time (c) KNOWLEDGECODE | MIT
*/
'use strict';(function(b,l){"object"===typeof exports&&"undefined"!==typeof module?module.exports=l():"function"===typeof define&&define.amd?define(l):(b="undefined"!==typeof globalThis?globalThis:b||self,b.date=l())})(this,function(){var b={},l={},n={},m="en",r={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"]},t={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)},
'use strict';(function(m,l){"object"===typeof exports&&"undefined"!==typeof module?module.exports=l():"function"===typeof define&&define.amd?define(l):(m="undefined"!==typeof globalThis?globalThis:m||self,m.date=l())})(this,function(){var m={},l={},q="en",r={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"]},v={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)},
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)},
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.utc?0:a.getTimezoneOffset()/.6;return(0<a?"-":"+")+("000"+Math.abs(a-a%100*.4)).slice(-4)},post:function(a){return a}},u={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,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/100|0)-a.value%100;return a},h12:function(a,c){return(12===a?0:a)+12*c},exec:function(a,
c){a=(a.exec(c)||[""])[0];return{value:a|0,length:a.length}},find:function(a,c){for(var b=-1,f=0,e=0,h=a.length,g;e<h;e++)g=a[e],!c.indexOf(g)&&g.length>f&&(b=e,f=g.length);return{value:b,length:f}},pre:function(a){return a}},q=function(a,c,b){var d=function(a,c,b){var d=function(a){a&&(this.res=a)};d.prototype=a;d.prototype.constructor=d;a=new d(b);for(var e in c||{})b=c[e],a[e]=b.slice?b.slice():b;return a},e={res:d(c.res,b.res)};e.formatter=d(c.formatter,b.formatter,e.res);e.parser=d(c.parser,
b.parser,e.res);l[a]=e};b.compile=function(a){for(var c=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,b,f=[a];b=c.exec(a);)f[f.length]=b[0];return f};b.format=function(a,c,d){c="string"===typeof c?b.compile(c):c;a=b.addMinutes(a,d?a.getTimezoneOffset():0);var f=l[m].formatter,e="";a.utc=d||!1;d=1;for(var h=c.length,g;d<h;d++)g=c[d],e+=f[g]?f.post(f[g](a,c[0])):g.replace(/\[(.*)]/,"$1");return e};b.preparse=function(a,c){c="string"===typeof c?b.compile(c):c;var d={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},f=/\[(.*)]/,e=l[m].parser,h=0;a=e.pre(a);for(var g=1,n=c.length,k,p;g<n;g++)if(k=c[g],e[k]){p=e[k](a.slice(h),c[0]);if(!p.length)break;h+=p.length;d[k.charAt(0)]=p.value;d._match++}else if(k===a.charAt(h)||" "===k)h++;else if(f.test(k)&&!a.slice(h).indexOf(f.exec(k)[1]))h+=k.length-2;else{"..."===k&&(h=a.length);break}d.H=d.H||e.h12(d.h,d.A);d._index=h;d._length=a.length;return d};b.isValid=function(a,c){a="string"===typeof a?b.preparse(a,c):a;c=[31,28+b.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>c||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-720>a.Z||840<a.Z)};b.parse=function(a,c,d){a=b.preparse(a,c);return b.isValid(a)?(a.M-=100>a.Y?22801:1,d||a.Z?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)};b.transform=function(a,c,d,f){return b.format(b.parse(a,c),d,f)};b.addYears=
function(a,c){return b.addMonths(a,12*c)};b.addMonths=function(a,c){a=new Date(a.getTime());a.setMonth(a.getMonth()+c);return a};b.addDays=function(a,c){a=new Date(a.getTime());a.setDate(a.getDate()+c);return a};b.addHours=function(a,c){return b.addMinutes(a,60*c)};b.addMinutes=function(a,c){return b.addSeconds(a,60*c)};b.addSeconds=function(a,c){return b.addMilliseconds(a,1E3*c)};b.addMilliseconds=function(a,c){return new Date(a.getTime()+c)};b.subtract=function(a,c){var b=a.getTime()-c.getTime();
return{toMilliseconds:function(){return b},toSeconds:function(){return b/1E3},toMinutes:function(){return b/6E4},toHours:function(){return b/36E5},toDays:function(){return b/864E5}}};b.isLeapYear=function(a){return!(a%4)&&!!(a%100)||!(a%400)};b.isSameDay=function(a,b){return a.toDateString()===b.toDateString()};b.locale=function(a,c){c?q(a,{res:r,formatter:t,parser:u},c):m=("function"===typeof a?a:b.locale[a]||function(){})(b)||m;return m};b.extend=function(a){var c=a.extender||{},d;for(d in c)b[d]||
(b[d]=c[d]);(a.formatter||a.parser||a.res)&&q(m,l[m],a)};b.plugin=function(a,c){c?n[a]||b.extend(n[a]=c):("function"===typeof a?a:b.plugin[a]||function(){})(b)};b.locale(m,{});return b})
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)},post:function(a){return a},res:r},w={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,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/100|0)-a.value%100;return a},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 c=-1,d=0,f=0,e=a.length,k;f<e;f++)k=a[f],!b.indexOf(k)&&k.length>d&&(c=f,d=k.length);return{value:c,length:d}},pre:function(a){return a},res:r},n=function(a,b,c,d){var f={},e;for(e in a)f[e]=a[e];for(e in b||{})!!c^!!f[e]||(f[e]=b[e]);d&&(f.res=d);return f},u={_formatter:v,_parser:w,compile:function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,c,d=[a];c=b.exec(a);)d[d.length]=c[0];return d},
format:function(a,b,c){b="string"===typeof b?this.compile(b):b;var d=a.getTimezoneOffset();a=this.addMinutes(a,c?d:0);var f=this._formatter,e="";a.getTimezoneOffset=function(){return c?0:d};for(var k=1,t=b.length,h;k<t;k++)h=b[k],e+=f[h]?f.post(f[h](a,b[0])):h.replace(/\[(.*)]/,"$1");return e},preparse:function(a,b){b="string"===typeof b?this.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},d=/\[(.*)]/,f=this._parser,e=0;a=f.pre(a);for(var k=1,t=b.length,
h,p;k<t;k++)if(h=b[k],f[h]){p=f[h](a.slice(e),b[0]);if(!p.length)break;e+=p.length;c[p.token||h.charAt(0)]=p.value;c._match++}else if(h===a.charAt(e)||" "===h)e++;else if(d.test(h)&&!a.slice(e).indexOf(d.exec(h)[1]))e+=h.length-2;else{"..."===h&&(e=a.length);break}c.H=c.H||f.h12(c.h,c.A);c._index=e;c._length=a.length;return c},parse:function(a,b,c){a=this.preparse(a,b);return this.isValid(a)?(a.M-=100>a.Y?22801:1,c||a.Z?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)},isValid:function(a,b){a="string"===typeof a?this.preparse(a,b):a;b=[31,28+this.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>b||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-720>a.Z||840<a.Z)},transform:function(a,b,c,d){return this.format(this.parse(a,b),c,d)},addYears:function(a,b){return this.addMonths(a,12*b)},addMonths:function(a,b){a=
new Date(a.getTime());a.setMonth(a.getMonth()+b);return a},addDays:function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a},addHours:function(a,b){return this.addMinutes(a,60*b)},addMinutes:function(a,b){return this.addSeconds(a,60*b)},addSeconds:function(a,b){return this.addMilliseconds(a,1E3*b)},addMilliseconds:function(a,b){return new Date(a.getTime()+b)},subtract:function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/
1E3},toMinutes:function(){return c/6E4},toHours:function(){return c/36E5},toDays:function(){return c/864E5}}},isLeapYear:function(a){return!(a%4)&&!!(a%100)||!(a%400)},isSameDay:function(a,b){return a.toDateString()===b.toDateString()},locale:function(a,b){m[a]||(m[a]=b)},plugin:function(a,b){l[a]||(l[a]=b)}},g=n(u);g.locale=function(a){a="function"===typeof a?a:g.locale[a];if(!a)return q;q=a(u);var b=m[q]||{},c=n(r,b.res,!0);a=n(v,b.formatter,!0,c);b=n(w,b.parser,!0,c);g._formatter=a;g._parser=b;
for(var d in l)g.extend(l[d]);return q};g.extend=function(a){var b=n(g._parser.res,a.res),c=a.extender||{};g._formatter=n(g._formatter,a.formatter,!1,b);g._parser=n(g._parser,a.parser,!1,b);for(var d in c)g[d]||(g[d]=c[d])};g.plugin=function(a){(a="function"===typeof a?a:g.plugin[a])&&g.extend(l[a(u)]||{})};return g})

@@ -5,4 +5,3 @@ /**

var date = {},
locales = {},
var locales = {},
plugins = {},

@@ -44,6 +43,7 @@ lang = 'en',

Z: function (d/*, formatString*/) {
var offset = d.utc ? 0 : d.getTimezoneOffset() / 0.6;
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - offset % 100 * 0.4)).slice(-4);
var offset = d.getTimezoneOffset() / 0.6 | 0;
return (offset > 0 ? '-' : '+') + ('000' + Math.abs(offset - (offset % 100 * 0.4 | 0))).slice(-4);
},
post: function (str) { return str; }
post: function (str) { return str; },
res: _res
},

@@ -109,29 +109,27 @@ _parser = {

},
pre: function (str) { return str; }
pre: function (str) { return str; },
res: _res
},
customize = function (code, base, locale) {
var extend = function (proto, props, res) {
var Locale = function (r) {
if (r) { this.res = r; }
};
extend = function (base, props, override, res) {
var obj = {}, key;
Locale.prototype = proto;
Locale.prototype.constructor = Locale;
for (key in base) {
obj[key] = base[key];
}
for (key in props || {}) {
if (!(!!override ^ !!obj[key])) {
obj[key] = props[key];
}
}
if (res) {
obj.res = res;
}
return obj;
};
var newLocale = new Locale(res),
value;
var proto = {
_formatter: _formatter,
_parser: _parser
};
for (var key in props || {}) {
value = props[key];
newLocale[key] = value.slice ? value.slice() : value;
}
return newLocale;
},
loc = { res: extend(base.res, locale.res) };
loc.formatter = extend(base.formatter, locale.formatter, loc.res);
loc.parser = extend(base.parser, locale.parser, loc.res);
locales[code] = loc;
};
/**

@@ -142,3 +140,3 @@ * Compiling a format string

*/
date.compile = function (formatString) {
proto.compile = function (formatString) {
var re = /\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g, keys, pattern = [formatString];

@@ -159,8 +157,9 @@

*/
date.format = function (dateObj, arg, utc) {
var pattern = typeof arg === 'string' ? date.compile(arg) : arg,
d = date.addMinutes(dateObj, utc ? dateObj.getTimezoneOffset() : 0),
formatter = locales[lang].formatter, str = '';
proto.format = function (dateObj, arg, utc) {
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
offset = dateObj.getTimezoneOffset(),
d = this.addMinutes(dateObj, utc ? offset : 0),
formatter = this._formatter, str = '';
d.utc = utc || false;
d.getTimezoneOffset = function () { return utc ? 0 : offset; };
for (var i = 1, len = pattern.length, token; i < len; i++) {

@@ -179,6 +178,6 @@ token = pattern[i];

*/
date.preparse = function (dateString, arg) {
var pattern = typeof arg === 'string' ? date.compile(arg) : arg,
proto.preparse = function (dateString, arg) {
var pattern = typeof arg === 'string' ? this.compile(arg) : arg,
dt = { 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 },
comment = /\[(.*)]/, parser = locales[lang].parser, offset = 0;
comment = /\[(.*)]/, parser = this._parser, offset = 0;

@@ -194,3 +193,3 @@ dateString = parser.pre(dateString);

offset += result.length;
dt[token.charAt(0)] = result.value;
dt[result.token || token.charAt(0)] = result.value;
dt._match++;

@@ -215,20 +214,2 @@ } else if (token === dateString.charAt(offset) || token === ' ') {

/**
* Validation
* @param {Object|string} arg1 - a date structure or a date string
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
* @returns {boolean} whether the date string is a valid date
*/
date.isValid = function (arg1, arg2) {
var dt = typeof arg1 === 'string' ? date.preparse(arg1, arg2) : arg1,
last = [31, 28 + date.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
return !(
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
dt.Z < -720 || dt.Z > 840
);
};
/**
* Parsing a Date and Time string

@@ -240,6 +221,6 @@ * @param {string} dateString - a date string

*/
date.parse = function (dateString, arg, utc) {
var dt = date.preparse(dateString, arg);
proto.parse = function (dateString, arg, utc) {
var dt = this.preparse(dateString, arg);
if (date.isValid(dt)) {
if (this.isValid(dt)) {
dt.M -= dt.Y < 100 ? 22801 : 1; // 22801 = 1900 * 12 + 1

@@ -255,2 +236,20 @@ if (utc || dt.Z) {

/**
* Validation
* @param {Object|string} arg1 - a date structure or a date string
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
* @returns {boolean} whether the date string is a valid date
*/
proto.isValid = function (arg1, arg2) {
var dt = typeof arg1 === 'string' ? this.preparse(arg1, arg2) : arg1,
last = [31, 28 + this.isLeapYear(dt.Y) | 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][dt.M - 1];
return !(
dt._index < 1 || dt._length < 1 || dt._index - dt._length || dt._match < 1 ||
dt.Y < 1 || dt.Y > 9999 || dt.M < 1 || dt.M > 12 || dt.D < 1 || dt.D > last ||
dt.H < 0 || dt.H > 23 || dt.m < 0 || dt.m > 59 || dt.s < 0 || dt.s > 59 || dt.S < 0 || dt.S > 999 ||
dt.Z < -720 || dt.Z > 840
);
};
/**
* Transforming a Date and Time string

@@ -263,4 +262,4 @@ * @param {string} dateString - a date string

*/
date.transform = function (dateString, arg1, arg2, utc) {
return date.format(date.parse(dateString, arg1), arg2, utc);
proto.transform = function (dateString, arg1, arg2, utc) {
return this.format(this.parse(dateString, arg1), arg2, utc);
};

@@ -274,4 +273,4 @@

*/
date.addYears = function (dateObj, years) {
return date.addMonths(dateObj, years * 12);
proto.addYears = function (dateObj, years) {
return this.addMonths(dateObj, years * 12);
};

@@ -285,3 +284,3 @@

*/
date.addMonths = function (dateObj, months) {
proto.addMonths = function (dateObj, months) {
var d = new Date(dateObj.getTime());

@@ -299,3 +298,3 @@

*/
date.addDays = function (dateObj, days) {
proto.addDays = function (dateObj, days) {
var d = new Date(dateObj.getTime());

@@ -313,4 +312,4 @@

*/
date.addHours = function (dateObj, hours) {
return date.addMinutes(dateObj, hours * 60);
proto.addHours = function (dateObj, hours) {
return this.addMinutes(dateObj, hours * 60);
};

@@ -324,4 +323,4 @@

*/
date.addMinutes = function (dateObj, minutes) {
return date.addSeconds(dateObj, minutes * 60);
proto.addMinutes = function (dateObj, minutes) {
return this.addSeconds(dateObj, minutes * 60);
};

@@ -335,4 +334,4 @@

*/
date.addSeconds = function (dateObj, seconds) {
return date.addMilliseconds(dateObj, seconds * 1000);
proto.addSeconds = function (dateObj, seconds) {
return this.addMilliseconds(dateObj, seconds * 1000);
};

@@ -346,3 +345,3 @@

*/
date.addMilliseconds = function (dateObj, milliseconds) {
proto.addMilliseconds = function (dateObj, milliseconds) {
return new Date(dateObj.getTime() + milliseconds);

@@ -357,3 +356,3 @@ };

*/
date.subtract = function (date1, date2) {
proto.subtract = function (date1, date2) {
var delta = date1.getTime() - date2.getTime();

@@ -385,3 +384,3 @@

*/
date.isLeapYear = function (y) {
proto.isLeapYear = function (y) {
return (!(y % 4) && !!(y % 100)) || !(y % 400);

@@ -396,3 +395,3 @@ };

*/
date.isSameDay = function (date1, date2) {
proto.isSameDay = function (date1, date2) {
return date1.toDateString() === date2.toDateString();

@@ -402,13 +401,52 @@ };

/**
* Changing the locale or defining new locales
* @param {Function|string} [code] - locale installer | language code
* @param {Object} [locale] - locale definition
* Defining new locale
* @param {string} code - language code
* @param {Function} locale - locale installer
* @returns {string} current language code
*/
date.locale = function (code, locale) {
if (locale) {
customize(code, { res: _res, formatter: _formatter, parser: _parser }, locale);
} else {
lang = (typeof code === 'function' ? code : date.locale[code] || function () {})(date) || lang;
proto.locale = function (code, locale) {
if (!locales[code]) {
locales[code] = locale;
}
};
/**
* Defining new plugin
* @param {string} name - plugin name
* @param {Function} plugin - plugin installer
* @returns {void}
*/
proto.plugin = function (name, plugin) {
if (!plugins[name]) {
plugins[name] = plugin;
}
};
var date = extend(proto);
/**
* Changing locale
* @param {Function|string} [locale] - locale object | language code
* @returns {string} current language code
*/
date.locale = function (locale) {
var install = typeof locale === 'function' ? locale : date.locale[locale];
if (!install) {
return lang;
}
lang = install(proto);
var extension = locales[lang] || {};
var res = extend(_res, extension.res, true);
var formatter = extend(_formatter, extension.formatter, true, res);
var parser = extend(_parser, extension.parser, true, res);
date._formatter = formatter;
date._parser = parser;
for (var plugin in plugins) {
date.extend(plugins[plugin]);
}
return lang;

@@ -423,4 +461,8 @@ };

date.extend = function (extension) {
var res = extend(date._parser.res, extension.res);
var extender = extension.extender || {};
date._formatter = extend(date._formatter, extension.formatter, false, res);
date._parser = extend(date._parser, extension.parser, false, res);
for (var key in extender) {

@@ -431,26 +473,17 @@ if (!date[key]) {

}
if (extension.formatter || extension.parser || extension.res) {
customize(lang, locales[lang], extension);
}
};
/**
* Importing or defining plugins
* @param {Function|string} name - plugin installer | plugin name
* @param {Object} [plugin] - plugin object
* Importing plugin
* @param {Function|string} plugin - plugin object | plugin name
* @returns {void}
*/
date.plugin = function (name, plugin) {
if (plugin) {
if (!plugins[name]) {
date.extend((plugins[name] = plugin));
}
} else {
(typeof name === 'function' ? name : date.plugin[name] || function () {})(date);
date.plugin = function (plugin) {
var install = typeof plugin === 'function' ? plugin : date.plugin[plugin];
if (install) {
date.extend(plugins[install(proto)] || {});
}
};
// Create default locale (English)
date.locale(lang, {});
export default date;
export { date as default };
/*
date-and-time (c) KNOWLEDGECODE | MIT
*/
var d={},l={},m={},p="en",q={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"]},r={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+
var g={},l={},m="en",p={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""+
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)},
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()]},
dd:function(a){return this.res.dd[a.getDay()]},Z:function(a){a=a.utc?0:a.getTimezoneOffset()/.6;return(0<a?"-":"+")+("000"+Math.abs(a-a%100*.4)).slice(-4)},post:function(a){return a}},t={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,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/100|0)-a.value%100;return a},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 c=-1,e=0,f=0,h=a.length,g;f<h;f++)g=a[f],!b.indexOf(g)&&g.length>e&&(c=f,e=g.length);return{value:c,length:e}},pre:function(a){return a}};
function u(a,b,c){function e(a,b,c){function e(a){a&&(this.res=a)}e.prototype=a;e.prototype.constructor=e;a=new e(c);for(var f in b||{})c=b[f],a[f]=c.slice?c.slice():c;return a}var f={res:e(b.res,c.res)};f.formatter=e(b.formatter,c.formatter,f.res);f.parser=e(b.parser,c.parser,f.res);l[a]=f}d.compile=function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,c,e=[a];c=b.exec(a);)e[e.length]=c[0];return e};
d.format=function(a,b,c){b="string"===typeof b?d.compile(b):b;a=d.addMinutes(a,c?a.getTimezoneOffset():0);var e=l[p].formatter,f="";a.utc=c||!1;c=1;for(var h=b.length,g;c<h;c++)g=b[c],f+=e[g]?e.post(e[g](a,b[0])):g.replace(/\[(.*)]/,"$1");return f};
d.preparse=function(a,b){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},e=/\[(.*)]/,f=l[p].parser,h=0;a=f.pre(a);for(var g=1,v=b.length,k,n;g<v;g++)if(k=b[g],f[k]){n=f[k](a.slice(h),b[0]);if(!n.length)break;h+=n.length;c[k.charAt(0)]=n.value;c._match++}else if(k===a.charAt(h)||" "===k)h++;else if(e.test(k)&&!a.slice(h).indexOf(e.exec(k)[1]))h+=k.length-2;else{"..."===k&&(h=a.length);break}c.H=c.H||f.h12(c.h,c.A);c._index=h;c._length=
a.length;return c};d.isValid=function(a,b){a="string"===typeof a?d.preparse(a,b):a;b=[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>b||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-720>a.Z||840<a.Z)};
d.parse=function(a,b,c){a=d.preparse(a,b);return d.isValid(a)?(a.M-=100>a.Y?22801:1,c||a.Z?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)};d.transform=function(a,b,c,e){return d.format(d.parse(a,b),c,e)};d.addYears=function(a,b){return d.addMonths(a,12*b)};d.addMonths=function(a,b){a=new Date(a.getTime());a.setMonth(a.getMonth()+b);return a};d.addDays=function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a};
d.addHours=function(a,b){return d.addMinutes(a,60*b)};d.addMinutes=function(a,b){return d.addSeconds(a,60*b)};d.addSeconds=function(a,b){return d.addMilliseconds(a,1E3*b)};d.addMilliseconds=function(a,b){return new Date(a.getTime()+b)};d.subtract=function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/1E3},toMinutes:function(){return c/6E4},toHours:function(){return c/36E5},toDays:function(){return c/864E5}}};
d.isLeapYear=function(a){return!(a%4)&&!!(a%100)||!(a%400)};d.isSameDay=function(a,b){return a.toDateString()===b.toDateString()};d.locale=function(a,b){b?u(a,{res:q,formatter:r,parser:t},b):p=("function"===typeof a?a:d.locale[a]||function(){})(d)||p;return p};d.extend=function(a){var b=a.extender||{},c;for(c in b)d[c]||(d[c]=b[c]);(a.formatter||a.parser||a.res)&&u(p,l[p],a)};d.plugin=function(a,b){b?m[a]||d.extend(m[a]=b):("function"===typeof a?a:d.plugin[a]||function(){})(d)};d.locale(p,{});
export default d
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)},post:function(a){return a},res:p},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,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?/,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},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 c=-1,d=0,f=0,e=a.length,k;f<e;f++)k=a[f],!b.indexOf(k)&&k.length>d&&(c=f,d=k.length);return{value:c,length:d}},pre:function(a){return a},
res:p};function u(a,b,c,d){var f={},e;for(e in a)f[e]=a[e];for(e in b||{})!!c^!!f[e]||(f[e]=b[e]);d&&(f.res=d);return f}
var v={_formatter:q,_parser:r,compile:function(a){for(var b=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,c,d=[a];c=b.exec(a);)d[d.length]=c[0];return d},format:function(a,b,c){b="string"===typeof b?this.compile(b):b;var d=a.getTimezoneOffset();a=this.addMinutes(a,c?d:0);var f=this._formatter,e="";a.getTimezoneOffset=function(){return c?0:d};for(var k=1,t=b.length,h;k<t;k++)h=b[k],e+=f[h]?f.post(f[h](a,b[0])):h.replace(/\[(.*)]/,"$1");return e},preparse:function(a,b){b="string"===typeof b?this.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},d=/\[(.*)]/,f=this._parser,e=0;a=f.pre(a);for(var k=1,t=b.length,h,n;k<t;k++)if(h=b[k],f[h]){n=f[h](a.slice(e),b[0]);if(!n.length)break;e+=n.length;c[n.token||h.charAt(0)]=n.value;c._match++}else if(h===a.charAt(e)||" "===h)e++;else if(d.test(h)&&!a.slice(e).indexOf(d.exec(h)[1]))e+=h.length-2;else{"..."===h&&(e=a.length);break}c.H=c.H||f.h12(c.h,c.A);c._index=e;c._length=a.length;return c},parse:function(a,b,c){a=this.preparse(a,
b);return this.isValid(a)?(a.M-=100>a.Y?22801:1,c||a.Z?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)},isValid:function(a,b){a="string"===typeof a?this.preparse(a,b):a;b=[31,28+this.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>b||0>a.H||23<a.H||0>a.m||59<a.m||0>a.s||59<a.s||0>a.S||999<a.S||-720>a.Z||840<a.Z)},transform:function(a,
b,c,d){return this.format(this.parse(a,b),c,d)},addYears:function(a,b){return this.addMonths(a,12*b)},addMonths:function(a,b){a=new Date(a.getTime());a.setMonth(a.getMonth()+b);return a},addDays:function(a,b){a=new Date(a.getTime());a.setDate(a.getDate()+b);return a},addHours:function(a,b){return this.addMinutes(a,60*b)},addMinutes:function(a,b){return this.addSeconds(a,60*b)},addSeconds:function(a,b){return this.addMilliseconds(a,1E3*b)},addMilliseconds:function(a,b){return new Date(a.getTime()+
b)},subtract:function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/1E3},toMinutes:function(){return c/6E4},toHours:function(){return c/36E5},toDays:function(){return c/864E5}}},isLeapYear:function(a){return!(a%4)&&!!(a%100)||!(a%400)},isSameDay:function(a,b){return a.toDateString()===b.toDateString()},locale:function(a,b){g[a]||(g[a]=b)},plugin:function(a,b){l[a]||(l[a]=b)}},w=u(v);
w.locale=function(a){a="function"===typeof a?a:w.locale[a];if(!a)return m;m=a(v);var b=g[m]||{},c=u(p,b.res,!0);a=u(q,b.formatter,!0,c);b=u(r,b.parser,!0,c);w._formatter=a;w._parser=b;for(var d in l)w.extend(l[d]);return m};w.extend=function(a){var b=u(w._parser.res,a.res),c=a.extender||{};w._formatter=u(w._formatter,a.formatter,!1,b);w._parser=u(w._parser,a.parser,!1,b);for(var d in c)w[d]||(w[d]=c[d])};w.plugin=function(a){(a="function"===typeof a?a:w.plugin[a])&&w.extend(l[a(v)]||{})};
export default w

@@ -39,2 +39,2 @@ /**

export default ar;
export { ar as default };

@@ -44,2 +44,2 @@ /**

export default az;
export { az as default };

@@ -50,2 +50,2 @@ /**

export default bn;
export { bn as default };

@@ -22,2 +22,2 @@ /**

export default cs;
export { cs as default };

@@ -23,2 +23,2 @@ /**

export default de;
export { de as default };

@@ -22,2 +22,2 @@ /**

export default dk;
export { dk as default };

@@ -12,4 +12,6 @@ /**

res: {
MMMM_nominative: ['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
MMMM_genitive: ['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου'],
MMMM: [
['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου']
],
MMM: ['Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μαϊ', 'Ιουν', 'Ιουλ', 'Αυγ', 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'],

@@ -23,3 +25,3 @@ dddd: ['Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο'],

MMMM: function (d, formatString) {
return this.res['MMMM_' + (/D.*MMMM/.test(formatString) ? 'genitive' : 'nominative')][d.getMonth()];
return this.res.MMMM[/D.*MMMM/.test(formatString) | 0][d.getMonth()];
},

@@ -35,3 +37,3 @@ hh: function (d) {

MMMM: function (str, formatString) {
var result = this.find(this.res['MMMM_' + (/D.*MMMM/.test(formatString) ? 'genitive' : 'nominative')], str);
var result = this.find(this.res.MMMM[/D.*MMMM/.test(formatString) | 0], str);
result.value++;

@@ -45,2 +47,2 @@ return result;

export default el;
export { el as default };

@@ -7,7 +7,8 @@ /**

var en = function () {
var en = function (date) {
var code = 'en';
return code;
};
export default en;
export { en as default };

@@ -42,2 +42,2 @@ /**

export default es;
export { es as default };

@@ -39,2 +39,2 @@ /**

export default fa;
export { fa as default };

@@ -23,2 +23,2 @@ /**

export default fr;
export { fr as default };

@@ -50,2 +50,2 @@ /**

export default hi;
export { hi as default };

@@ -23,2 +23,2 @@ /**

export default hu;
export { hu as default };

@@ -46,2 +46,2 @@ /**

export default id;
export { id as default };

@@ -23,2 +23,2 @@ /**

export default it;
export { it as default };

@@ -31,2 +31,2 @@ /**

export default ja;
export { ja as default };

@@ -46,2 +46,2 @@ /**

export default jv;
export { jv as default };

@@ -23,2 +23,2 @@ /**

export default ko;
export { ko as default };

@@ -38,2 +38,2 @@ /**

export default my;
export { my as default };

@@ -13,4 +13,6 @@ /**

MMMM: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
MMM_withdots: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
MMM_withoutdots: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
MMM: [
['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
],
dddd: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],

@@ -22,3 +24,3 @@ ddd: ['zo.', 'ma.', 'di.', 'wo.', 'do.', 'vr.', 'za.'],

MMM: function (d, formatString) {
return this.res['MMM_' + (/-MMM-/.test(formatString) ? 'withoutdots' : 'withdots')][d.getMonth()];
return this.res.MMM[/-MMM-/.test(formatString) | 0][d.getMonth()];
}

@@ -28,3 +30,3 @@ },

MMM: function (str, formatString) {
var result = this.find(this.res['MMM_' + (/-MMM-/.test(formatString) ? 'withoutdots' : 'withdots')], str);
var result = this.find(this.res.MMM[/-MMM-/.test(formatString) | 0], str);
result.value++;

@@ -38,2 +40,2 @@ return result;

export default nl;
export { nl as default };

@@ -62,2 +62,2 @@ /**

export default pa_in;
export { pa_in as default };

@@ -12,4 +12,6 @@ /**

res: {
MMMM_nominative: ['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
MMMM_subjective: ['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia'],
MMMM: [
['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia']
],
MMM: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru'],

@@ -22,3 +24,3 @@ dddd: ['niedziela', 'poniedziałek', 'wtorek', 'środa', 'czwartek', 'piątek', 'sobota'],

MMMM: function (d, formatString) {
return this.res['MMMM_' + (/D MMMM/.test(formatString) ? 'subjective' : 'nominative')][d.getMonth()];
return this.res.MMMM[/D MMMM/.test(formatString) | 0][d.getMonth()];
}

@@ -28,3 +30,3 @@ },

MMMM: function (str, formatString) {
var result = this.find(this.res['MMMM_' + (/D MMMM/.test(formatString) ? 'subjective' : 'nominative')], str);
var result = this.find(this.res.MMMM[/D MMMM/.test(formatString) | 0], str);
result.value++;

@@ -38,2 +40,2 @@ return result;

export default pl;
export { pl as default };

@@ -44,2 +44,2 @@ /**

export default pt;
export { pt as default };

@@ -22,2 +22,2 @@ /**

export default ro;
export { ro as default };

@@ -44,2 +44,2 @@ /**

export default ru;
export { ru as default };

@@ -22,2 +22,2 @@ /**

export default rw;
export { rw as default };

@@ -22,2 +22,2 @@ /**

export default sr;
export { sr as default };

@@ -23,2 +23,2 @@ /**

export default th;
export { th as default };

@@ -22,2 +22,2 @@ /**

export default tr;
export { tr as default };

@@ -14,5 +14,7 @@ /**

MMM: ['січ', 'лют', 'бер', 'квіт', 'трав', 'черв', 'лип', 'серп', 'вер', 'жовт', 'лист', 'груд'],
dddd_nominative: ['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
dddd_accusative: ['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
dddd_genitive: ['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи'],
dddd: [
['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи']
],
ddd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],

@@ -35,9 +37,9 @@ dd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],

dddd: function (d, formatString) {
var type = 'nominative';
var type = 0;
if (/(\[[ВвУу]\]) ?dddd/.test(formatString)) {
type = 'accusative';
type = 1;
} else if (/\[?(?:минулої|наступної)? ?\] ?dddd/.test(formatString)) {
type = 'genitive';
type = 2;
}
return this.res['dddd_' + type][d.getDay()];
return this.res.dddd[type][d.getDay()];
}

@@ -57,2 +59,2 @@ },

export default uk;
export { uk as default };

@@ -22,2 +22,2 @@ /**

export default uz;
export { uz as default };

@@ -23,2 +23,2 @@ /**

export default vi;
export { vi as default };

@@ -48,2 +48,2 @@ /**

export default zh_cn;
export { zh_cn as default };

@@ -46,2 +46,2 @@ /**

export default zh_tw;
export { zh_tw as default };

@@ -19,2 +19,2 @@ /**

export default plugin;
export { plugin as default };

@@ -11,23 +11,32 @@ /**

res: {
A: ['AM', 'PM', 'A.M.', 'P.M.', 'am', 'pm', 'a.m.', 'p.m.']
AA: ['A.M.', 'P.M.'],
a: ['am', 'pm'],
aa: ['a.m.', 'p.m.']
},
formatter: {
AA: function (d) {
// A.M. / P.M.
return this.res.A[d.getHours() > 11 | 0 + 2];
return this.res.AA[d.getHours() > 11 | 0];
},
a: function (d) {
// am / pm
return this.res.A[d.getHours() > 11 | 0 + 4];
return this.res.a[d.getHours() > 11 | 0];
},
aa: function (d) {
// a.m. / p.m.
return this.res.A[d.getHours() > 11 | 0 + 6];
return this.res.aa[d.getHours() > 11 | 0];
}
},
parser: {
A: function (str) {
var result = this.find(this.res.A, str);
result.value %= 2;
AA: function (str) {
var result = this.find(this.res.AA, str);
result.token = 'A';
return result;
},
a: function (str) {
var result = this.find(this.res.a, str);
result.token = 'A';
return result;
},
aa: function (str) {
var result = this.find(this.res.aa, str);
result.token = 'A';
return result;
}

@@ -39,2 +48,2 @@ }

export default plugin;
export { plugin as default };

@@ -31,2 +31,2 @@ /**

export default plugin;
export { plugin as default };

@@ -34,2 +34,2 @@ /**

export default plugin;
export { plugin as default };

@@ -75,2 +75,2 @@ /**

export default plugin;
export { plugin as default };

@@ -15,7 +15,2 @@ /**

return result;
},
Y: function (str) {
var result = this.exec(/^\d\d?/, str);
result.value += result.value < 70 ? 2000 : 1900;
return result;
}

@@ -27,2 +22,2 @@ }

export default plugin;
export { plugin as default };

@@ -26,10 +26,24 @@ # Extension

- To the parser, it is not able to add token of new alphabet.
- Only tokens consisting of the following alphabets can be added to the parser.
```javascript
'EEE' // This is not able to add because `E` is not an existing token in the parser.
'YYY' // This is OK because `Y` token is existing in the parser.
'SSS' // This is modifying, not adding. Because exactly the same token is existing.
'Y' // Year
'M' // Month
'D' // Day
'H' // 24-hour
'A' // AM PM
'h' // 12-hour
's' // Second
'S' // Millisecond
'Z' // Timezone offset
```
- Existing tokens cannot be overwritten.
```javascript
'YYY' // This is OK because the same token does not exists.
'SSS' // This cannot be added because the exact same token exists.
'EEE' // This is OK for the formatter, but cannot be added to the parser.
```
## Examples

@@ -65,8 +79,8 @@

In the parser, modify `MMM` token to ignore case:
Add `MMMMM` token to the parser. This token ignores case:
```javascript
date.parse('Dec 25 2019', 'MMM DD YYYY'); // => December 25, 2019
date.parse('dec 25 2019', 'MMM DD YYYY'); // => December 25, 2019
date.parse('DEC 25 2019', 'MMM DD YYYY'); // => December 25, 2019
date.parse('Dec 25 2019', 'MMMMM DD YYYY'); // => December 25, 2019
date.parse('dec 25 2019', 'MMMMM DD YYYY'); // => December 25, 2019
date.parse('DEC 25 2019', 'MMMMM DD YYYY'); // => December 25, 2019
```

@@ -81,3 +95,3 @@

parser: {
MMM: function (str) {
MMMMM: function (str) {
const mmm = this.res.MMM.map(m => m.toLowerCase());

@@ -92,2 +106,2 @@ const result = this.find(mmm, str.toLowerCase());

Modifying the parser may be a bit difficult. Refer to the library source code to grasp the default behavior.
Extending the parser may be a bit difficult. Refer to the library source code to grasp the default behavior.

@@ -18,4 +18,6 @@ (function (global, factory) {

res: {
MMMM_nominative: ['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
MMMM_genitive: ['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου'],
MMMM: [
['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],
['Ιανουαρίου', 'Φεβρουαρίου', 'Μαρτίου', 'Απριλίου', 'Μαΐου', 'Ιουνίου', 'Ιουλίου', 'Αυγούστου', 'Σεπτεμβρίου', 'Οκτωβρίου', 'Νοεμβρίου', 'Δεκεμβρίου']
],
MMM: ['Ιαν', 'Φεβ', 'Μαρ', 'Απρ', 'Μαϊ', 'Ιουν', 'Ιουλ', 'Αυγ', 'Σεπ', 'Οκτ', 'Νοε', 'Δεκ'],

@@ -29,3 +31,3 @@ dddd: ['Κυριακή', 'Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο'],

MMMM: function (d, formatString) {
return this.res['MMMM_' + (/D.*MMMM/.test(formatString) ? 'genitive' : 'nominative')][d.getMonth()];
return this.res.MMMM[/D.*MMMM/.test(formatString) | 0][d.getMonth()];
},

@@ -41,3 +43,3 @@ hh: function (d) {

MMMM: function (str, formatString) {
var result = this.find(this.res['MMMM_' + (/D.*MMMM/.test(formatString) ? 'genitive' : 'nominative')], str);
var result = this.find(this.res.MMMM[/D.*MMMM/.test(formatString) | 0], str);
result.value++;

@@ -44,0 +46,0 @@ return result;

@@ -13,4 +13,5 @@ (function (global, factory) {

var en = function () {
var en = function (date) {
var code = 'en';
return code;

@@ -17,0 +18,0 @@ };

@@ -19,4 +19,6 @@ (function (global, factory) {

MMMM: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
MMM_withdots: ['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
MMM_withoutdots: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
MMM: [
['jan.', 'feb.', 'mrt.', 'apr.', 'mei', 'jun.', 'jul.', 'aug.', 'sep.', 'okt.', 'nov.', 'dec.'],
['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']
],
dddd: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],

@@ -28,3 +30,3 @@ ddd: ['zo.', 'ma.', 'di.', 'wo.', 'do.', 'vr.', 'za.'],

MMM: function (d, formatString) {
return this.res['MMM_' + (/-MMM-/.test(formatString) ? 'withoutdots' : 'withdots')][d.getMonth()];
return this.res.MMM[/-MMM-/.test(formatString) | 0][d.getMonth()];
}

@@ -34,3 +36,3 @@ },

MMM: function (str, formatString) {
var result = this.find(this.res['MMM_' + (/-MMM-/.test(formatString) ? 'withoutdots' : 'withdots')], str);
var result = this.find(this.res.MMM[/-MMM-/.test(formatString) | 0], str);
result.value++;

@@ -37,0 +39,0 @@ return result;

@@ -18,4 +18,6 @@ (function (global, factory) {

res: {
MMMM_nominative: ['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
MMMM_subjective: ['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia'],
MMMM: [
['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],
['stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca', 'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia']
],
MMM: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru'],

@@ -28,3 +30,3 @@ dddd: ['niedziela', 'poniedziałek', 'wtorek', 'środa', 'czwartek', 'piątek', 'sobota'],

MMMM: function (d, formatString) {
return this.res['MMMM_' + (/D MMMM/.test(formatString) ? 'subjective' : 'nominative')][d.getMonth()];
return this.res.MMMM[/D MMMM/.test(formatString) | 0][d.getMonth()];
}

@@ -34,3 +36,3 @@ },

MMMM: function (str, formatString) {
var result = this.find(this.res['MMMM_' + (/D MMMM/.test(formatString) ? 'subjective' : 'nominative')], str);
var result = this.find(this.res.MMMM[/D MMMM/.test(formatString) | 0], str);
result.value++;

@@ -37,0 +39,0 @@ return result;

@@ -20,5 +20,7 @@ (function (global, factory) {

MMM: ['січ', 'лют', 'бер', 'квіт', 'трав', 'черв', 'лип', 'серп', 'вер', 'жовт', 'лист', 'груд'],
dddd_nominative: ['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
dddd_accusative: ['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
dddd_genitive: ['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи'],
dddd: [
['неділя', 'понеділок', 'вівторок', 'середа', 'четвер', 'п’ятниця', 'субота'],
['неділю', 'понеділок', 'вівторок', 'середу', 'четвер', 'п’ятницю', 'суботу'],
['неділі', 'понеділка', 'вівторка', 'середи', 'четверга', 'п’ятниці', 'суботи']
],
ddd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],

@@ -41,9 +43,9 @@ dd: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],

dddd: function (d, formatString) {
var type = 'nominative';
var type = 0;
if (/(\[[ВвУу]\]) ?dddd/.test(formatString)) {
type = 'accusative';
type = 1;
} else if (/\[?(?:минулої|наступної)? ?\] ?dddd/.test(formatString)) {
type = 'genitive';
type = 2;
}
return this.res['dddd_' + type][d.getDay()];
return this.res.dddd[type][d.getDay()];
}

@@ -50,0 +52,0 @@ },

{
"name": "date-and-time",
"version": "1.0.1",
"version": "2.0.0",
"description": "A Minimalist DateTime utility for Node.js and the browser",

@@ -47,8 +47,8 @@ "main": "date-and-time.js",

"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.26.0",
"@ampproject/rollup-plugin-closure-compiler": "^0.27.0",
"expect.js": "^0.3.1",
"mocha": "^8.4.0",
"mocha": "^9.0.3",
"mocha-headless-chrome": "^3.1.0",
"rollup": "^2.50.5"
"rollup": "^2.56.2"
}
}

@@ -17,23 +17,32 @@ (function (global, factory) {

res: {
A: ['AM', 'PM', 'A.M.', 'P.M.', 'am', 'pm', 'a.m.', 'p.m.']
AA: ['A.M.', 'P.M.'],
a: ['am', 'pm'],
aa: ['a.m.', 'p.m.']
},
formatter: {
AA: function (d) {
// A.M. / P.M.
return this.res.A[d.getHours() > 11 | 0 + 2];
return this.res.AA[d.getHours() > 11 | 0];
},
a: function (d) {
// am / pm
return this.res.A[d.getHours() > 11 | 0 + 4];
return this.res.a[d.getHours() > 11 | 0];
},
aa: function (d) {
// a.m. / p.m.
return this.res.A[d.getHours() > 11 | 0 + 6];
return this.res.aa[d.getHours() > 11 | 0];
}
},
parser: {
A: function (str) {
var result = this.find(this.res.A, str);
result.value %= 2;
AA: function (str) {
var result = this.find(this.res.AA, str);
result.token = 'A';
return result;
},
a: function (str) {
var result = this.find(this.res.a, str);
result.token = 'A';
return result;
},
aa: function (str) {
var result = this.find(this.res.aa, str);
result.token = 'A';
return result;
}

@@ -40,0 +49,0 @@ }

@@ -21,7 +21,2 @@ (function (global, factory) {

return result;
},
Y: function (str) {
var result = this.exec(/^\d\d?/, str);
result.value += result.value < 70 ? 2000 : 1900;
return result;
}

@@ -28,0 +23,0 @@ }

# Plugins
This library is oriented towards minimalism, so it may appear to be lacking in features. Plugin is the most realistic solution to such dissatisfaction. By importing plugins, you can extend the functionality of this library, mainly formatter and parser.
This library is oriented towards minimalism, so it may seem to some developers to be lacking in features. Plugin is the most realistic solution to such dissatisfaction. By importing plugins, you can extend the functionality of this library, mainly a formatter and a parser.
*The formatter is used in `format()`, etc., the parser is used in `parse()`, `preparse()`, `isValid()`, etc.*
## Usage

@@ -55,3 +57,3 @@

### NOTE
### Note

@@ -63,9 +65,9 @@ - If you want to use ES Modules in Node.js without a transpiler, you need to add `"type": "module"` in your `package.json` or change your file extension from `.js` to `.mjs`.

- [day-of-week](#day-of-week)
- It adds day of week notation to the parser.
- It adds *"dummy"* tokens for `day of week` to the parser.
- [meridiem](#meridiem)
- It extends `A` token.
- It adds various notations for `AM PM`.
- [microsecond](#microsecond)
- It adds microsecond notation to the parser.
- It adds tokens for microsecond to the parser.

@@ -76,19 +78,28 @@ - [ordinal](#ordinal)

- [timespan](#timespan)
- It adds `timeSpan()` function to the library.
- It adds `timeSpan()` function that calculates the difference of two dates to the library.
- [timezone](#timezone)
- It adds `formatTZ()` and `parseTZ()` functions that support `IANA time zone names` to the library.
- [two-digit-year](#two-digit-year)
- It adds two-digit year notation to the parser.
## Plugin Details
---
### day-of-week
It adds `dddd`, `ddd` and `dd` tokens to the parser. While these meanings are as follows, in fact they don't make sense because day of week doesn't include information to determine a date:
It adds tokens for `day of week` to the parser. Although `day of week` is not significant information for the parser to identify a date, these tokens are sometimes useful. For example, when a string to be parsed contains a day of week, and you just want to skip it.
| token | meaning | examples of acceptable form | added or modified |
|:------|:-------------------------|:----------------------------|:------------------|
| dddd | day of week (long) | Friday, Sunday | ✔ |
| ddd | day of week (short) | Fri, Sun | ✔ |
| dd | day of week (very short) | Fr, Su | ✔ |
**formatter:**
There is no change.
**parser:**
| token | meaning | acceptable examples |
|:------|:-----------|:--------------------|
| dddd | long | Friday, Sunday |
| ddd | short | Fri, Sun |
| dd | very short | Fr, Su |
```javascript

@@ -109,19 +120,24 @@ const date = require('date-and-time');

---
### meridiem
It adds `AA`, `a` and `aa` tokens to the formatter. These meanings are as follows:
It adds various notations for AM PM.
| token | meaning | examples of output | added or modified |
|:------|:-----------------------------------|:-------------------|:------------------|
| A | meridiem (uppercase) | AM, PM | |
| AA | meridiem (uppercase with ellipsis) | A.M., P.M. | ✔ |
| a | meridiem (lowercase) | am, pm | ✔ |
| aa | meridiem (lowercase with ellipsis) | a.m., p.m. | ✔ |
**formatter:**
It also extends `A` token of the parser as follows:
| token | meaning | output examples |
|:------|:------------------------|:----------------|
| AA | uppercase with ellipsis | A.M., P.M. |
| a | lowercase | am, pm |
| aa | lowercase with ellipsis | a.m., p.m. |
| token | meaning | examples of acceptable form | added or modified |
|:------|:---------------------------------|:---------------------------------------|:------------------|
| A | all the above notations | AM, PM, A.M., P.M., am, pm, a.m., p.m. | ✔ |
**parser:**
| token | meaning | acceptable examples |
|:------|:------------------------|:--------------------|
| AA | uppercase with ellipsis | A.M., P.M. |
| a | lowercase | am, pm |
| aa | lowercase with ellipsis | a.m., p.m. |
```javascript

@@ -143,22 +159,31 @@ const date = require('date-and-time');

// The parser will be acceptable all the above notations with only `A` token.
// This is default behavior of the parser.
date.parse('12:34 PM', 'hh:mm A'); // => Jan 1 1970 12:34:00
date.parse('12:34 P.M.', 'hh:mm A'); // => Jan 1 1970 12:34:00
date.parse('12:34 pm', 'hh:mm A'); // => Jan 1 1970 12:34:00
date.parse('12:34 p.m.', 'hh:mm A'); // => Jan 1 1970 12:34:00
// These are added tokens to the parser.
date.parse('12:34 P.M.', 'hh:mm AA'); // => Jan 1 1970 12:34:00
date.parse('12:34 pm', 'hh:mm a'); // => Jan 1 1970 12:34:00
date.parse('12:34 p.m.', 'hh:mm aa'); // => Jan 1 1970 12:34:00
```
This plugin has a **breaking change**. In previous versions, the `A` token for the parser could parse various notations for AM PM, but in the new version, it can only parse `AM` and `PM`. For other notations, a dedicated token is now provided for each.
---
### microsecond
It adds `SSSSSS`, `SSSSS` and `SSSS` tokens to the parser. Thease meanings are as follows:
It adds tokens for microsecond to the parser. If a time string to be parsed contains microsecond, these tokens are useful. In JS, however, it is not supported microsecond accuracy, a parsed value is rounded to millisecond accuracy.
| token | meaning | examples of output | added or modified |
|:-------|:------------------------------|:-------------------|:------------------|
| SSSSSS | microsecond (high accuracy) | 753123, 022113 | ✔ |
| SSSSS | microsecond (middle accuracy) | 75312, 02211 | ✔ |
| SSSS | microsecond (low accuracy) | 7531, 0221 | ✔ |
| SSS | millisecond (high accuracy) | 753, 022 | |
| SS | millisecond (middle accuracy) | 75, 02 | |
| S | millisecond (low accuracy) | 7, 0 | |
**formatter:**
There is no change.
**parser:**
| token | meaning | acceptable examples |
|:-------|:----------------|:--------------------|
| SSSSSS | high accuracy | 753123, 022113 |
| SSSSS | middle accuracy | 75312, 02211 |
| SSSS | low accuracy | 7531, 0221 |
```javascript

@@ -172,3 +197,3 @@ const date = require('date-and-time');

// A date object in JavaScript supports `millisecond` (ms):
// A date object in JavaScript supports `millisecond` (ms) like this:
date.parse('12:34:56.123', 'HH:mm:ss.SSS');

@@ -182,12 +207,18 @@

---
### ordinal
It adds `DDD` token to the formatter. This meaning is as follows:
It adds `DDD` token that output ordinal notation of date to the formatter.
| token | meaning | examples of output | added or modified |
|:------|:-------------------------|:--------------------|:------------------|
| DDD | ordinal notation of date | 1st, 2nd, 3rd, 31th | ✔ |
| DD | date with zero-padding | 01, 02, 03, 31 | |
| D | date | 1, 2, 3, 31 | |
**formatter:**
| token | meaning | output examples |
|:------|:-------------------------|:--------------------|
| DDD | ordinal notation of date | 1st, 2nd, 3rd, 31th |
**parser:**
There is no change.
```javascript

@@ -209,6 +240,14 @@ const date = require('date-and-time');

---
### timespan
It adds `timeSpan()` function to the library. This function is similar to the `subtract()`, but this can display a formatted elapsed time between two date objects:
It adds `timeSpan()` function that calculates the difference of two dates to the library. This function is similar to `subtract()`, the difference is that it can format the calculation results.
#### timeSpan(date1, date2)
- @param {**Date**} date1 - a Date object
- @param {**Date**} date2 - a Date object
- @returns {**Object**} a result object subtracting date2 from date1
```javascript

@@ -230,3 +269,3 @@ const date = require('date-and-time');

The `timeSpan()` returns an object that has some functions as with the `subtract()`:
Like `subtract()`, `timeSpan()` returns an object with functions like this:

@@ -241,3 +280,3 @@ | function | description |

Available tokens in those functions and their meanings are as follows:
In these functions can be available some tokens to format the calculation result. Here are the tokens and their meanings:

@@ -260,14 +299,101 @@ | function | available tokens |

---
### timezone
It adds `formatTZ()` and `parseTZ()` functions that support `IANA time zone names` (`America/Los_Angeles`, `Asia/Tokyo`, and so on) to the library.
#### formatTZ(dateObj, arg[, timeZone])
- @param {**Date**} dateObj - a Date object
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
- @param {**string**} [timeZone] - output as this time zone
- @returns {**string**} a formatted string
The `formatTZ()` is upward compatible with `format()`. Tokens available here are the same as for the `format()`. If the `timeZone` is omitted, it output the date string with local time zone.
#### parseTZ(dateString, arg[, timeZone])
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
- @param {**string**} [timeZone] - input as this time zone
- @returns {**Date**} a constructed date
The `parseTZ()` is upward compatible with `parse()`. Tokens available here are the same as for the `parse()`. If the `timeZone` is omitted, the time zone of the date string is assumed to be local time zone.
```javascript
const date = require('date-and-time');
// Import "timezone" plugin.
const timezone = require('date-and-time/plugin/timezone');
// Apply "timezone" plugin to the library.
date.plugin(timezone);
const d1 = new Date(Date.UTC(2021, 2, 14, 9, 59, 59, 999)); // 2021-03-14T09:59:59.999Z
date.formatTZ(d1, 'MMMM DD YYYY H:mm:ss.SSS [UTC]Z', 'America/Los_Angeles'); // March 14 2021 1:59:59.999 UTC-0800
const d2 = new Date(Date.UTC(2021, 2, 14, 10, 0, 0, 0)); // 2021-03-14T10:00:00.000Z
date.formatTZ(d2, 'MMMM DD YYYY H:mm:ss.SSS [UTC]Z', 'America/Los_Angeles'); // March 14 2021 3:00:00.000 UTC-0700
// Parses the date string assuming that the time zone is "Pacific/Honolulu" (UTC-1000).
date.parseTZ('Sep 25 2021 4:00:00', 'MMM D YYYY H:mm:ss', 'Pacific/Honolulu'); // 2021-09-25T14:00:00.000Z
// Parses the date string assuming that the time zone is "Europe/London" (UTC+0100).
date.parseTZ('Sep 25 2021 4:00:00', 'MMM D YYYY H:mm:ss', 'Europe/London'); // 2021-09-25T03:00:00.000Z
```
#### Caveats
- This plugin uses the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) object to parse `IANA time zone names`. Note that if you use this plugin in older browsers, this may **NOT** be supported there. At least it does not work in IE.
- If you don't need to use `IANA time zone names`, you should not use this plugin for performance reasons. The `format()` and the `parse()` are enough.
#### Start of DST (Daylight Saving Time)
For example, in the US, when local standard time is about to reach Sunday, 14 March 2021, `02:00:00` clocks are turned `forward` 1 hour to Sunday, 14 March 2021, `03:00:00` local daylight time instead. Thus, there is no `02:00:00` to `02:59:59` on 14 March 2021. In such edge cases, the `parseTZ()` will parse like this:
```javascript
date.parseTZ('Mar 14 2021 1:59:59', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-03-14T09:59:59Z
date.parseTZ('Mar 14 2021 2:00:00', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => NaN
date.parseTZ('Mar 14 2021 2:59:59', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => NaN
date.parseTZ('Mar 14 2021 3:00:00', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-03-14T10:00:00Z
```
#### End of DST
Also, when local daylight time is about to reach Sunday, 7 November 2021, `02:00:00` clocks are turned `backward` 1 hour to Sunday, 7 November 2021, `01:00:00` local standard time instead. Thus, `01:00:00` to `01:59:59` on November 7 2021 is repeated twice. Since there are two possible times between them, DST or not, the `parseTZ()` assumes that the time is former to make the result unique:
```javascript
// The parseTZ() assumes that this time is DST.
date.parseTZ('Nov 7 2021 1:59:59', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-11-07T08:59:59Z
// This time is already PST.
date.parseTZ('Nov 7 2021 2:00:00', 'MMM D YYYY H:mm:ss', 'America/Los_Angeles'); // => 2021-11-07T10:00:00Z
```
At the first example above, if you want the parser to parse the time as PST (Pacific Standard Time), use the `parse()` with a time offset instead:
```javascript
date.parse('Nov 7 2021 1:59:59 -0800', 'MMM D YYYY H:mm:ss Z'); // => 2021-11-07T09:59:59Z
```
---
### two-digit-year
It adds `YY` token to the parser and also changes behavior of `Y` token. These meanings are as follows:
It adds `YY` token to the parser. This token will convert the year 69 or earlier to 2000s, the year 70 or later to 1900s. In brief:
| token | meaning | examples of acceptable form | added or modified |
|:------|:------------------------------------|:----------------------------|:------------------|
| YYYY | four-digit year | 2019, 0123, 0001 | |
| YY | two-digit year | 90, 00, 08, 19 | ✔ |
| Y | two-digit year without zero-padding | 90, 0, 8, 19 | ✔ |
| examples | result |
|:------------------------|:-------|
| 00, 01, 02, ..., 68, 69 | 2000s |
| 70, 71, 72, ..., 98, 99 | 1900s |
`YY` and `Y` token will convert the year 69 or earlier to 2000s, the year 70 or later to 1900s. By this change, `Y` token will no longer acceptable the year 100 or later, so use `YYYY` token instead if necessary.
**formatter:**
There is no change.
**parser:**
| token | meaning | acceptable examples |
|:------|:---------------|:--------------------|
| YY | two-digit year | 90, 00, 08, 19 |
```javascript

@@ -278,5 +404,4 @@ const date = require('date-and-time');

// These are default behavior of the parser.
// This is the default behavior of the parser.
date.parse('Dec 25 69', 'MMM D YY'); // => Invalid Date
date.parse('Dec 25 70', 'MMM D Y'); // => 70 AD (ancient times)

@@ -286,10 +411,7 @@ // Apply the "two_digit_year" plugin to the library.

// These convert the year 69 or earlier to 2000s, the year 70 or later to 1900s.
// The `YY` token convert the year 69 or earlier to 2000s, the year 70 or later to 1900s.
date.parse('Dec 25 69', 'MMM D YY'); // => Dec 25 2069
date.parse('Dec 25 70', 'MMM D Y'); // => Dec 25 1970
date.parse('Dec 25 70', 'MMM D YY'); // => Dec 25 1970
```
// `Y` token will no longer acceptable the year 100 or later.
date.parse('Dec 25 2019', 'MMM D Y'); // => Invalid Date
// Use `YYYY` token instead if necessary.
date.parse('Dec 25 2019', 'MMM D YYYY'); // => Dec 25 2019
```
This plugin has a **breaking change**. In previous versions, this plugin overrode the default behavior of the `Y` token, but this has been obsolete.

@@ -27,2 +27,7 @@ # date-and-time

- 2.0.0
- Fixed a conflict when importing multiple plugins and locales.
- **Breaking Changes!** Due to the above fix, the specifications of plugin, locale, and extension have been changed. The `meridiem` plugin and the `two-digit-year` plugin are now partially incompatible with previous ones. See [here](./PLUGINS.md) for details. Also the `extend()` function has changed. If you are using it, check [here](./EXTEND.md) for any impact. The locales are still compatible.
- Added `timezone` plugin. You can now use the IANA timezone name to output a datetime string or input a date object. See [PLUGINS.md](./PLUGINS.md) for details.
- 1.0.1

@@ -36,5 +41,2 @@ - Updated dev dependencies to resolve vulnerability.

- 0.14.2
- Fixed regular expression denial of service (ReDoS) vulnerability.
## Usage

@@ -74,3 +76,3 @@

- [format](#formatdateobj-formatstring-utc)
- [format](#formatdateobj-arg-utc)
- Formatting a Date and Time (Date -> String)

@@ -132,3 +134,3 @@

### format(dateObj, formatString[, utc])
### format(dateObj, arg[, utc])

@@ -214,3 +216,3 @@ - @param {**Date**} dateObj - a Date object

- @param {string} dateString - a date string
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object

@@ -232,39 +234,40 @@ - @param {**boolean**} [utc] - input as UTC

| token | meaning | examples of acceptable form |
|:-------|:-------------------------------------|:---------------------------------------|
| YYYY | four-digit year | 0999, 2015 |
| Y | four-digit year without zero-padding | 2, 44, 88, 2015 |
| MMMM | month name (long) | January, December |
| MMM | month name (short) | Jan, Dec |
| MM | month with zero-padding | 01, 12 |
| M | month | 1, 12 |
| DD | date with zero-padding | 02, 31 |
| D | date | 2, 31 |
| HH | 24-hour with zero-padding | 23, 08 |
| H | 24-hour | 23, 8 |
| hh | 12-hour with zero-padding | 11, 08 |
| h | 12-hour | 11, 8 |
| A | meridiem (uppercase) | AM, PM |
| mm | minute with zero-padding | 14, 07 |
| m | minute | 14, 7 |
| ss | second with zero-padding | 05, 10 |
| s | second | 5, 10 |
| SSS | millisecond (high accuracy) | 753, 022 |
| SS | millisecond (middle accuracy) | 75, 02 |
| S | millisecond (low accuracy) | 7, 0 |
| Z | timezone offset | +0100, -0800 |
| token | meaning | examples of acceptable form |
|:-------|:-------------------------------------|:----------------------------|
| YYYY | four-digit year | 0999, 2015 |
| Y | four-digit year without zero-padding | 2, 44, 88, 2015 |
| MMMM | month name (long) | January, December |
| MMM | month name (short) | Jan, Dec |
| MM | month with zero-padding | 01, 12 |
| M | month | 1, 12 |
| DD | date with zero-padding | 02, 31 |
| D | date | 2, 31 |
| HH | 24-hour with zero-padding | 23, 08 |
| H | 24-hour | 23, 8 |
| hh | 12-hour with zero-padding | 11, 08 |
| h | 12-hour | 11, 8 |
| A | meridiem (uppercase) | AM, PM |
| mm | minute with zero-padding | 14, 07 |
| m | minute | 14, 7 |
| ss | second with zero-padding | 05, 10 |
| s | second | 5, 10 |
| SSS | millisecond (high accuracy) | 753, 022 |
| SS | millisecond (middle accuracy) | 75, 02 |
| S | millisecond (low accuracy) | 7, 0 |
| Z | timezone offset | +0100, -0800 |
You can also use the following tokens by importing plugins. See [PLUGINS.md](./PLUGINS.md) for details.
| token | meaning | examples of acceptable form |
|:-------|:-------------------------------------|:---------------------------------------|
| YY | two-digit year | 90, 00, 08, 19 |
| Y | two-digit year without zero-padding | 90, 0, 8, 19 |
| A | meridiem | AM, PM, A.M., P.M., am, pm, a.m., p.m. |
| dddd | day of week (long) | Friday, Sunday |
| ddd | day of week (short) | Fri, Sun |
| dd | day of week (very short) | Fr, Su |
| SSSSSS | microsecond (high accuracy) | 123456, 000001 |
| SSSSS | microsecond (middle accuracy) | 12345, 00001 |
| SSSS | microsecond (low accuracy) | 1234, 0001 |
| token | meaning | examples of acceptable form |
|:-------|:-------------------------------------|:----------------------------|
| YY | two-digit year | 90, 00, 08, 19 |
| AA | meridiem (uppercase with ellipsis) | A.M., P.M. |
| a | meridiem (lowercase) | am, pm |
| aa | meridiem (lowercase with ellipsis) | a.m., p.m. |
| dddd | day of week (long) | Friday, Sunday |
| ddd | day of week (short) | Fri, Sun |
| dd | day of week (very short) | Fr, Su |
| SSSSSS | microsecond (high accuracy) | 123456, 000001 |
| SSSSS | microsecond (middle accuracy) | 12345, 00001 |
| SSSS | microsecond (low accuracy) | 1234, 0001 |

@@ -578,3 +581,3 @@ #### Note 1. Invalid Date

It extends the formatter and the parser of the current locale. See [EXTEND.md](./EXTEND.md) for details.
It extends this library. See [EXTEND.md](./EXTEND.md) for details.

@@ -587,3 +590,3 @@ ### plugin(name[, plugin])

Plugin is a named extension object. By installing predefined plugins, you can easily extend the formatter and the parser of the current locale. See [PLUGINS.md](./PLUGINS.md) for details.
Plugin is a named extension object. By installing predefined plugins, you can easily extend this library. See [PLUGINS.md](./PLUGINS.md) for details.

@@ -590,0 +593,0 @@ ## Browser Support

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc