Socket
Socket
Sign inDemoInstall

date-and-time

Package Overview
Dependencies
0
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.14.2 to 1.0.0

esm/date-and-time.es.js

118

date-and-time.js

@@ -1,7 +0,11 @@

/**
* @preserve date-and-time.js (c) KNOWLEDGECODE | MIT
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.date = factory());
}(this, (function () { 'use strict';
/**
* @preserve date-and-time (c) KNOWLEDGECODE | MIT
*/
var date = {},

@@ -44,3 +48,6 @@ locales = {},

dd: function (d/*, formatString*/) { return this.res.dd[d.getDay()]; },
Z: function (d/*, formatString*/) { return d.utc ? '+0000' : /[\+-]\d{4}/.exec(d.toTimeString())[0]; },
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);
},
post: function (str) { return str; }

@@ -135,3 +142,3 @@ },

/**
* compiling a format string
* Compiling a format string
* @param {string} formatString - a format string

@@ -150,5 +157,5 @@ * @returns {Array.<string>} a compiled object

/**
* formatting a date
* Formatting a Date and Time
* @param {Date} dateObj - a Date object
* @param {string|Array.<string>} arg - a format string or a compiled object
* @param {string|Array.<string>} arg - a format string or its compiled object
* @param {boolean} [utc] - output as UTC

@@ -171,5 +178,5 @@ * @returns {string} a formatted string

/**
* pre-parsing a date string
* Pre-parsing a Date and Time string
* @param {string} dateString - a date string
* @param {string|Array.<string>} arg - a format string or a compiled object
* @param {string|Array.<string>} arg - a format string or its compiled object
* @returns {Object} a date structure

@@ -211,5 +218,5 @@ */

/**
* validation
* Validation
* @param {Object|string} arg1 - a date structure or a date string
* @param {string|Array.<string>} [arg2] - a format string or a compiled object
* @param {string|Array.<string>} [arg2] - a format string or its compiled object
* @returns {boolean} whether the date string is a valid date

@@ -230,5 +237,5 @@ */

/**
* parsing a date string
* Parsing a Date and Time string
* @param {string} dateString - a date string
* @param {string|Array.<string>} arg - a format string or a compiled object
* @param {string|Array.<string>} arg - a format string or its compiled object
* @param {boolean} [utc] - input as UTC

@@ -251,6 +258,6 @@ * @returns {Date} a constructed date

/**
* transformation of date string
* Transforming a Date and Time string
* @param {string} dateString - a date string
* @param {string|Array.<string>} arg1 - the format string of the date string or the compiled object
* @param {string|Array.<string>} arg2 - the transformed format string or the compiled object
* @param {string|Array.<string>} arg1 - a format string or its compiled object
* @param {string|Array.<string>} arg2 - a transformed format string or its compiled object
* @param {boolean} [utc] - output as UTC

@@ -264,3 +271,3 @@ * @returns {string} a formatted string

/**
* adding years
* Adding years
* @param {Date} dateObj - a date object

@@ -275,3 +282,3 @@ * @param {number} years - number of years to add

/**
* adding months
* Adding months
* @param {Date} dateObj - a date object

@@ -289,3 +296,3 @@ * @param {number} months - number of months to add

/**
* adding days
* Adding days
* @param {Date} dateObj - a date object

@@ -303,3 +310,3 @@ * @param {number} days - number of days to add

/**
* adding hours
* Adding hours
* @param {Date} dateObj - a date object

@@ -314,3 +321,3 @@ * @param {number} hours - number of hours to add

/**
* adding minutes
* Adding minutes
* @param {Date} dateObj - a date object

@@ -325,3 +332,3 @@ * @param {number} minutes - number of minutes to add

/**
* adding seconds
* Adding seconds
* @param {Date} dateObj - a date object

@@ -336,3 +343,3 @@ * @param {number} seconds - number of seconds to add

/**
* adding milliseconds
* Adding milliseconds
* @param {Date} dateObj - a date object

@@ -347,3 +354,3 @@ * @param {number} milliseconds - number of milliseconds to add

/**
* subtracting
* Subtracting two dates
* @param {Date} date1 - a Date object

@@ -376,5 +383,5 @@ * @param {Date} date2 - a Date object

/**
* leap year
* Whether year is leap year
* @param {number} y - year
* @returns {boolean} whether the year is a leap year
* @returns {boolean} whether year is leap year
*/

@@ -386,6 +393,6 @@ date.isLeapYear = function (y) {

/**
* comparison of two dates
* Comparison of two dates
* @param {Date} date1 - a Date object
* @param {Date} date2 - a Date object
* @returns {boolean} whether the dates are the same day (times are ignored)
* @returns {boolean} whether the two dates are the same day (time is ignored)
*/

@@ -397,4 +404,4 @@ date.isSameDay = function (date1, date2) {

/**
* change locale or setting a new locale definition
* @param {Function|string} [code] - locale function | language code
* Changing the locale or defining new locales
* @param {Function|string} [code] - locale installer | language code
* @param {Object} [locale] - locale definition

@@ -406,9 +413,4 @@ * @returns {string} current language code

customize(code, { res: _res, formatter: _formatter, parser: _parser }, locale);
} else if (typeof code === 'function') {
lang = code(date);
} else if (code) {
if (global && !global.date) {
console.warn('This method of changing the locale is deprecated. See documentation for details.');
}
lang = code;
} else {
lang = (typeof code === 'function' ? code : date.locale[code] || function () {})(date) || lang;
}

@@ -419,4 +421,4 @@ return lang;

/**
* locale extension
* @param {Object} extension - locale extension
* Feature extension
* @param {Object} extension - extension object
* @returns {void}

@@ -438,18 +440,14 @@ */

/**
* plugin import or definition
* @param {Function|string} plugin - plugin function | plugin name
* @param {Object} [extension] - locale extension
* Importing or defining plugins
* @param {Function|string} name - plugin installer | plugin name
* @param {Object} [plugin] - plugin object
* @returns {void}
*/
date.plugin = function (plugin, extension) {
if (typeof plugin === 'function') {
date.extend(plugins[plugin(date)]);
date.plugin = function (name, plugin) {
if (plugin) {
if (!plugins[name]) {
date.extend((plugins[name] = plugin));
}
} else {
plugins[plugin] = plugins[plugin] || extension;
if (!extension && plugins[plugin]) {
date.extend(plugins[plugin]);
if (global && !global.date) {
console.warn('This method of applying plugins is deprecated. See documentation for details.');
}
}
(typeof name === 'function' ? name : date.plugin[name] || function () {})(date);
}

@@ -461,12 +459,4 @@ };

if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = date;
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return date;
});
} else {
global.date = date;
}
return date;
}(this));
})));
/*
date-and-time.js (c) KNOWLEDGECODE | MIT
date-and-time (c) KNOWLEDGECODE | MIT
*/
(function(q){var d={},t={},r={},m="en",v={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"]},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)},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){return a.utc?"+0000":/[\+-]\d{4}/.exec(a.toTimeString())[0]},post:function(a){return a}},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,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){var b=(a.exec(c)||[""])[0];return{value:b|0,length:b.length}},find:function(a,c){for(var b=-1,e=0,g=0,h=a.length,f;g<h;g++)f=a[g],!c.indexOf(f)&&f.length>e&&(b=g,e=f.length);return{value:b,length:e}},pre:function(a){return a}},u=function(a,
c,b){var e=function(h,f,l){var p=function(n){n&&(this.res=n)};p.prototype=h;p.prototype.constructor=p;h=new p(l);for(var k in f||{})l=f[k],h[k]=l.slice?l.slice():l;return h},g={res:e(c.res,b.res)};g.formatter=e(c.formatter,b.formatter,g.res);g.parser=e(c.parser,b.parser,g.res);t[a]=g};d.compile=function(a){for(var c=/\[([^\[\]]|\[[^\[\]]*])*]|([A-Za-z])\2+|\.{3}|./g,b,e=[a];b=c.exec(a);)e[e.length]=b[0];return e};d.format=function(a,c,b){c="string"===typeof c?d.compile(c):c;a=d.addMinutes(a,b?a.getTimezoneOffset():
0);var e=t[m].formatter,g="";a.utc=b||!1;b=1;for(var h=c.length,f;b<h;b++)f=c[b],g+=e[f]?e.post(e[f](a,c[0])):f.replace(/\[(.*)]/,"$1");return g};d.preparse=function(a,c){var b="string"===typeof c?d.compile(c):c,e={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},g=/\[(.*)]/,h=t[m].parser,f=0;a=h.pre(a);for(var l=1,p=b.length,k,n;l<p;l++)if(k=b[l],h[k]){n=h[k](a.slice(f),b[0]);if(!n.length)break;f+=n.length;e[k.charAt(0)]=n.value;e._match++}else if(k===a.charAt(f)||" "===k)f++;
else if(g.test(k)&&!a.slice(f).indexOf(g.exec(k)[1]))f+=k.length-2;else{"..."===k&&(f=a.length);break}e.H=e.H||h.h12(e.h,e.A);e._index=f;e._length=a.length;return e};d.isValid=function(a,c){var b="string"===typeof a?d.preparse(a,c):a,e=[31,28+d.isLeapYear(b.Y)|0,31,30,31,30,31,31,30,31,30,31][b.M-1];return!(1>b._index||1>b._length||b._index-b._length||1>b._match||1>b.Y||9999<b.Y||1>b.M||12<b.M||1>b.D||b.D>e||0>b.H||23<b.H||0>b.m||59<b.m||0>b.s||59<b.s||0>b.S||999<b.S||-720>b.Z||840<b.Z)};d.parse=
function(a,c,b){a=d.preparse(a,c);return d.isValid(a)?(a.M-=100>a.Y?22801:1,b||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,c,b,e){return d.format(d.parse(a,c),b,e)};d.addYears=function(a,c){return d.addMonths(a,12*c)};d.addMonths=function(a,c){var b=new Date(a.getTime());b.setMonth(b.getMonth()+c);return b};d.addDays=function(a,c){var b=new Date(a.getTime());b.setDate(b.getDate()+c);return b};d.addHours=function(a,
c){return d.addMinutes(a,60*c)};d.addMinutes=function(a,c){return d.addSeconds(a,60*c)};d.addSeconds=function(a,c){return d.addMilliseconds(a,1E3*c)};d.addMilliseconds=function(a,c){return new Date(a.getTime()+c)};d.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}}};d.isLeapYear=function(a){return!(a%4)&&!!(a%100)||
!(a%400)};d.isSameDay=function(a,c){return a.toDateString()===c.toDateString()};d.locale=function(a,c){c?u(a,{res:v,formatter:w,parser:x},c):"function"===typeof a?m=a(d):a&&(q&&!q.date&&console.warn("This method of changing the locale is deprecated. See documentation for details."),m=a);return m};d.extend=function(a){var c=a.extender||{},b;for(b in c)d[b]||(d[b]=c[b]);(a.formatter||a.parser||a.res)&&u(m,t[m],a)};d.plugin=function(a,c){"function"===typeof a?d.extend(r[a(d)]):(r[a]=r[a]||c,!c&&r[a]&&
(d.extend(r[a]),q&&!q.date&&console.warn("This method of applying plugins is deprecated. See documentation for details.")))};d.locale(m,{});"object"===typeof module&&"object"===typeof module.exports?module.exports=d:"function"===typeof define&&define.amd?define([],function(){return d}):q.date=d})(this);
'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)},
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})
# Extension
By using `extend()`, you could add your own tokens or modify behavior of existing tokens. This is equivalent to define a new plugin without name.
The easiest way to extend the default formatter and parser is to use plugins, but if the existing plugins do not meet your requirements, you can extend them yourself.

@@ -5,0 +5,0 @@ ## Token

# Locale
The `format()` outputs month, day of week, and meridiem (am / pm) in English, and the `parse()` assumes the passed date string is in English. Here it describes how to use other languages in these functions.
By default, `format()` outputs month, day of week, and meridiem (AM / PM) in English, and functions such as `parse()` assume that a passed date time string is in English. Here it describes how to use other languages in these functions.
## Usage
To support `ES Modules` in the next version, the locale switching method has changed and then the old method has been deprecated.
- ES Modules:
```javascript
import date from 'date-and-time';
import es from 'date-and-time/locale/es';
date.locale(es); // Spanish
date.format(new Date(), 'dddd D MMMM'); // => 'lunes 11 enero
```
- CommonJS:

@@ -19,10 +27,12 @@

- ES Modules (with transpile):
- ES Modules for the browser:
```javascript
import date from 'date-and-time';
import it from 'date-and-time/locale/it';
```html
<script type="module">
import date from '/path/to/date-and-time.es.min.js';
import it from '/path/to/date-and-time/locale/it.es.js';
date.locale(it); // Italian
date.format(new Date(), 'dddd D MMMM'); // => 'Lunedì 11 gennaio'
</script>
```

@@ -32,4 +42,2 @@

When in older browser, pass the locale string as before. (no changes)
```html

@@ -47,5 +55,5 @@ <script src="/path/to/date-and-time.min.js"></script>

- You have to import (or require) in advance the all locale modules that you are going to switch to.
- 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`.
- The locale will be actually switched after executing the `locale()`.
- You can also change the locale back to English by loading the `en` module:
- You can also change the locale back to English by importing `en` locale:

@@ -58,26 +66,2 @@ ```javascript

### FYI
The following (old) methods are deprecated. In the next version it won't be able to use them.
- CommonJS:
```javascript
const date = require('date-and-time');
require('date-and-time/locale/fr');
date.locale('fr'); // French
date.format(new Date(), 'dddd D MMMM'); // => 'lundi 11 janvier'
```
- ES Modules (with transpile):
```javascript
import date from 'date-and-time';
import 'date-and-time/locale/it';
date.locale('it'); // Italian
date.format(new Date(), 'dddd D MMMM'); // => 'Lunedì 11 gennaio'
```
## Supported locale List

@@ -107,2 +91,3 @@

Javanese (jv)
Kinyarwanda (rw)
Korean (ko)

@@ -109,0 +94,0 @@ Persian (fa)

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Arabic (ar)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ar = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Arabic (ar)
* @preserve It is using moment.js locale configuration as a reference.
*/
var ar = function (date) {
var code = 'ar';

@@ -41,13 +45,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return ar;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Azerbaijani (az)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.az = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Azerbaijani (az)
* @preserve It is using moment.js locale configuration as a reference.
*/
var az = function (date) {
var code = 'az';

@@ -46,13 +50,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return az;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Bengali (bn)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.bn = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Bengali (bn)
* @preserve It is using moment.js locale configuration as a reference.
*/
var bn = function (date) {
var code = 'bn';

@@ -52,13 +56,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return bn;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Czech (cs)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.cs = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Czech (cs)
* @preserve It is using moment.js locale configuration as a reference.
*/
var cs = function (date) {
var code = 'cs';

@@ -24,13 +28,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return cs;
}(this));
})));

@@ -1,13 +0,17 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve German (de)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.de = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve German (de)
* @preserve It is using moment.js locale configuration as a reference.
*/
var de = function (date) {
var code = 'de';
date.locale('de', {
date.locale(code, {
res: {

@@ -25,13 +29,4 @@ MMMM: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return de;
}(this));
})));

@@ -1,13 +0,17 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Danish (DK)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.dk = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Danish (DK)
* @preserve It is using moment.js locale configuration as a reference.
*/
var dk = function (date) {
var code = 'dk';
date.locale('dk', {
date.locale(code, {
res: {

@@ -24,13 +28,4 @@ MMMM: ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'december'],

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return dk;
}(this));
})));

@@ -1,13 +0,17 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Greek (el)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.el = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Greek (el)
* @preserve It is using moment.js locale configuration as a reference.
*/
var el = function (date) {
var code = 'el';
date.locale('el', {
date.locale(code, {
res: {

@@ -44,13 +48,4 @@ MMMM_nominative: ['Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάιος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος'],

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return el;
}(this));
})));

@@ -1,23 +0,20 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Englis (en)
* @preserve This is a dummy module.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.en = factory()));
}(this, (function () { 'use strict';
var exec = function () {
return 'en';
/**
* @preserve date-and-time.js locale configuration
* @preserve Englis (en)
* @preserve This is a dummy module.
*/
var en = function () {
var code = 'en';
return code;
};
if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return en;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Spanish (es)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.es = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Spanish (es)
* @preserve It is using moment.js locale configuration as a reference.
*/
var es = function (date) {
var code = 'es';

@@ -44,13 +48,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return es;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Persian (fa)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.fa = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Persian (fa)
* @preserve It is using moment.js locale configuration as a reference.
*/
var fa = function (date) {
var code = 'fa';

@@ -41,13 +45,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return fa;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve French (fr)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.fr = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve French (fr)
* @preserve It is using moment.js locale configuration as a reference.
*/
var fr = function (date) {
var code = 'fr';

@@ -25,13 +29,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return fr;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Hindi (hi)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.hi = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Hindi (hi)
* @preserve It is using moment.js locale configuration as a reference.
*/
var hi = function (date) {
var code = 'hi';

@@ -52,13 +56,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return hi;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Hungarian (hu)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.hu = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Hungarian (hu)
* @preserve It is using moment.js locale configuration as a reference.
*/
var hu = function (date) {
var code = 'hu';

@@ -25,13 +29,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return hu;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Indonesian (id)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.id = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Indonesian (id)
* @preserve It is using moment.js locale configuration as a reference.
*/
var id = function (date) {
var code = 'id';

@@ -48,13 +52,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return id;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Italian (it)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.it = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Italian (it)
* @preserve It is using moment.js locale configuration as a reference.
*/
var it = function (date) {
var code = 'it';

@@ -25,13 +29,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return it;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Japanese (ja)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ja = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Japanese (ja)
* @preserve It is using moment.js locale configuration as a reference.
*/
var ja = function (date) {
var code = 'ja';

@@ -33,13 +37,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return ja;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Javanese (jv)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.jv = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Javanese (jv)
* @preserve It is using moment.js locale configuration as a reference.
*/
var jv = function (date) {
var code = 'jv';

@@ -48,13 +52,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return jv;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Korean (ko)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ko = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Korean (ko)
* @preserve It is using moment.js locale configuration as a reference.
*/
var ko = function (date) {
var code = 'ko';

@@ -25,13 +29,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return ko;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Burmese (my)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.my = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Burmese (my)
* @preserve It is using moment.js locale configuration as a reference.
*/
var my = function (date) {
var code = 'my';

@@ -40,13 +44,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return my;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Dutch (nl)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.nl = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Dutch (nl)
* @preserve It is using moment.js locale configuration as a reference.
*/
var nl = function (date) {
var code = 'nl';

@@ -37,13 +41,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return nl;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Punjabi (pa-in)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale['pa-in'] = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Punjabi (pa-in)
* @preserve It is using moment.js locale configuration as a reference.
*/
var pa_in = function (date) {
var code = 'pa-in';

@@ -64,13 +68,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return pa_in;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Polish (pl)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.pl = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Polish (pl)
* @preserve It is using moment.js locale configuration as a reference.
*/
var pl = function (date) {
var code = 'pl';

@@ -37,13 +41,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return pl;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Portuguese (pt)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.pt = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Portuguese (pt)
* @preserve It is using moment.js locale configuration as a reference.
*/
var pt = function (date) {
var code = 'pt';

@@ -46,13 +50,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return pt;
}(this));
})));

@@ -1,13 +0,17 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Romanian (ro)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ro = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Romanian (ro)
* @preserve It is using moment.js locale configuration as a reference.
*/
var ro = function (date) {
var code = 'ro';
date.locale('ro', {
date.locale(code, {
res: {

@@ -24,13 +28,4 @@ MMMM: ['ianuarie', 'februarie', 'martie', 'aprilie', 'mai', 'iunie', 'iulie', 'august', 'septembrie', 'octombrie', 'noiembrie', 'decembrie'],

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return ro;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Russian (ru)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.ru = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Russian (ru)
* @preserve It is using moment.js locale configuration as a reference.
*/
var ru = function (date) {
var code = 'ru';

@@ -46,13 +50,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return ru;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Serbian (sr)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.sr = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Serbian (sr)
* @preserve It is using moment.js locale configuration as a reference.
*/
var sr = function (date) {
var code = 'sr';

@@ -24,13 +28,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return sr;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Thai (th)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.th = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Thai (th)
* @preserve It is using moment.js locale configuration as a reference.
*/
var th = function (date) {
var code = 'th';

@@ -25,13 +29,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return th;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Turkish (tr)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.tr = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Turkish (tr)
* @preserve It is using moment.js locale configuration as a reference.
*/
var tr = function (date) {
var code = 'tr';

@@ -24,13 +28,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return tr;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Ukrainian (uk)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.uk = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Ukrainian (uk)
* @preserve It is using moment.js locale configuration as a reference.
*/
var uk = function (date) {
var code = 'uk';

@@ -57,13 +61,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return uk;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Uzbek (uz)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.uz = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Uzbek (uz)
* @preserve It is using moment.js locale configuration as a reference.
*/
var uz = function (date) {
var code = 'uz';

@@ -24,13 +28,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return uz;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Vietnamese (vi)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale.vi = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Vietnamese (vi)
* @preserve It is using moment.js locale configuration as a reference.
*/
var vi = function (date) {
var code = 'vi';

@@ -25,13 +29,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return vi;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Chinese (zh-cn)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale['zh-cn'] = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Chinese (zh-cn)
* @preserve It is using moment.js locale configuration as a reference.
*/
var zh_cn = function (date) {
var code = 'zh-cn';

@@ -50,13 +54,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return zh_cn;
}(this));
})));

@@ -1,10 +0,14 @@

/**
* @preserve date-and-time.js locale configuration
* @preserve Chinese (zh-tw)
* @preserve It is using moment.js locale configuration as a reference.
*/
(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.locale = global.date.locale || {}, global.date.locale['zh-tw'] = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js locale configuration
* @preserve Chinese (zh-tw)
* @preserve It is using moment.js locale configuration as a reference.
*/
var zh_tw = function (date) {
var code = 'zh-tw';

@@ -48,13 +52,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return zh_tw;
}(this));
})));
{
"name": "date-and-time",
"version": "0.14.2",
"version": "1.0.0",
"description": "A Minimalist DateTime utility for Node.js and the browser",
"main": "date-and-time.js",
"module": "esm/date-and-time.es.js",
"unpkg": "date-and-time.min.js",
"exports": {
".": {
"browser": "./esm/date-and-time.es.js",
"import": "./esm/date-and-time.mjs",
"require": "./date-and-time.js"
},
"./locale/*": {
"browser": "./esm/locale/*.es.js",
"import": "./esm/locale/*.mjs",
"require": "./locale/*.js"
},
"./plugin/*": {
"browser": "./esm/plugin/*.es.js",
"import": "./esm/plugin/*.mjs",
"require": "./plugin/*.js"
}
},
"scripts": {
"test": "./test.sh",
"compile": "./compile.sh date-and-time.js date-and-time.min.js"
"build": "rollup --config rollup.config.js",
"test": "./test.sh"
},

@@ -28,12 +47,8 @@ "repository": {

"devDependencies": {
"babel-preset-env": "^1.7.0",
"babelify": "^7.3.0",
"browserify": "^16.5.2",
"@ampproject/rollup-plugin-closure-compiler": "^0.26.0",
"expect.js": "^0.3.1",
"mocha": "^7.2.0",
"mocha-headless-chrome": "^3.1.0"
},
"browser": {
"date-and-time": "./date-and-time.js"
"mocha": "^8.3.2",
"mocha-headless-chrome": "^3.1.0",
"rollup": "^2.44.0"
}
}

@@ -1,5 +0,13 @@

(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin['day-of-week'] = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js plugin
* @preserve day-of-week
*/
var plugin = function (date) {
var name = 'day-of-week';

@@ -17,13 +25,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return plugin;
}(this));
})));

@@ -1,5 +0,13 @@

(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.meridiem = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js plugin
* @preserve meridiem
*/
var plugin = function (date) {
var name = 'meridiem';

@@ -36,13 +44,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return plugin;
}(this));
})));

@@ -1,8 +0,16 @@

(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.microsecond = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js plugin
* @preserve microsecond
*/
var plugin = function (date) {
var name = 'microsecond';
date.plugin('microsecond', {
date.plugin(name, {
parser: {

@@ -29,13 +37,4 @@ SSSSSS: function (str) {

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return plugin;
}(this));
})));

@@ -1,5 +0,13 @@

(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.ordinal = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js plugin
* @preserve ordinal
*/
var plugin = function (date) {
var name = 'ordinal';

@@ -32,13 +40,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return plugin;
}(this));
})));

@@ -1,5 +0,13 @@

(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin.timespan = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js plugin
* @preserve timespan
*/
var plugin = function (date) {
var timeSpan = function (date1, date2) {

@@ -73,13 +81,4 @@ var milliseconds = function (dt, time) {

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return plugin;
}(this));
})));

@@ -1,5 +0,13 @@

(function (global) {
'use strict';
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (global.date = global.date || {}, global.date.plugin = global.date.plugin || {}, global.date.plugin['two-digit-year'] = factory()));
}(this, (function () { 'use strict';
var exec = function (date) {
/**
* @preserve date-and-time.js plugin
* @preserve two-digit-year
*/
var plugin = function (date) {
var name = 'two-digit-year';

@@ -24,13 +32,4 @@

if (typeof module === 'object' && typeof module.exports === 'object') {
(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));
} else if (typeof define === 'function' && define.amd) {
define(['date-and-time'], exec);
} else {
exec(global.date);
}
return plugin;
}(this));
})));
# Plugins
As this library is oriented toward minimalism, it may seem like a lack of functionality. We think plugin is the most realistic solution for solving such dissatisfaction. By importing the plugins, you can extend the functionality of this library, mainly the formatter and the parser.
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.
## Usage
To support `ES Modules` in the next version, the importing method has changed and then the old method has been deprecated.
- ES Modules:
```javascript
import date from 'date-and-time';
// Import the plugin named "foobar".
import foobar from 'date-and-time/plugin/foobar';
// Apply the "foobar" to the library.
date.plugin(foobar);
```
- CommonJS:

@@ -13,18 +22,20 @@

const date = require('date-and-time');
// Import the plugin "foobar".
// Import the plugin named "foobar".
const foobar = require('date-and-time/plugin/foobar');
// Apply the plugin to "date-and-time".
// Apply the "foobar" to the library.
date.plugin(foobar);
```
- ES Modules (with transpile):
- ES Modules for the browser:
```javascript
import date from 'date-and-time';
// Import the plugin "foobar".
import foobar from 'date-and-time/plugin/foobar';
```html
<script type="module">
import date from '/path/to/date-and-time.es.min.js';
// Import the plugin named "foobar".
import foobar from '/path/to/date-and-time/plugin/foobar.es.js';
// Apply the plugin to "date-and-time".
// Apply the "foobar" to the library.
date.plugin(foobar);
</script>
```

@@ -34,11 +45,9 @@

When in older browser, pass the plugin name as before. (no changes)
```html
<script src="/path/to/date-and-time.min.js"></script>
<!-- Import the plugin "foobar". -->
<!-- Import the plugin named "foobar". -->
<script src="/path/to/plugin/foobar.js"></script>
<script>
// Apply the plugin to "date-and-time".
// Apply the "foobar" to the library.
date.plugin('foobar');

@@ -48,46 +57,24 @@ </script>

### FYI
### NOTE
The following (old) methods are deprecated. In the next version it won't be able to use them.
- 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`.
- CommonJS:
```javascript
const date = require('date-and-time');
// Import the plugin "foobar".
require('date-and-time/plugin/foobar');
// Apply the plugin to "date-and-time".
date.plugin('foobar');
```
- ES Modules (with transpile):
```javascript
import date from 'date-and-time';
// Import the plugin "foobar".
import 'date-and-time/plugin/foobar';
// Apply the plugin to "date-and-time".
date.plugin('foobar');
```
## Plugin List
- day-of-week
- [day-of-week](#day-of-week)
- It adds day of week notation to the parser.
- meridiem
- [meridiem](#meridiem)
- It extends `A` token.
- microsecond
- [microsecond](#microsecond)
- It adds microsecond notation to the parser.
- ordinal
- [ordinal](#ordinal)
- It adds ordinal notation of date to the formatter.
- timespan
- [timespan](#timespan)
- It adds `timeSpan()` function to the library.
- two-digit-year
- [two-digit-year](#two-digit-year)
- It adds two-digit year notation to the parser.

@@ -109,6 +96,6 @@

const date = require('date-and-time');
// Import "day-of-week" plugin.
// Import "day-of-week" plugin as a named "day_of_week".
const day_of_week = require('date-and-time/plugin/day-of-week');
// Apply "day-of-week" plugin to `date-and-time`.
// Apply the "day_of_week" plugin to the library.
date.plugin(day_of_week);

@@ -145,3 +132,3 @@

// Apply "medidiem" plugin to `date-and-time`.
// Apply "medidiem" plugin to the library.
date.plugin(meridiem);

@@ -182,3 +169,3 @@

// Apply "microsecond" plugin to `date-and-time`.
// Apply "microsecond" plugin to the library.
date.plugin(microsecond);

@@ -210,3 +197,3 @@

// Apply "ordinal" plugin to `date-and-time`.
// Apply "ordinal" plugin to the library.
date.plugin(ordinal);

@@ -231,3 +218,3 @@

// Apply "timespan" plugin to `date-and-time`.
// Apply "timespan" plugin to the library.
date.plugin(timespan);

@@ -285,3 +272,3 @@

const date = require('date-and-time');
// Import "two-digit-year" plugin.
// Import "two-digit-year" plugin as a named "two_digit_year".
const two_digit_year = require('date-and-time/plugin/two-digit-year');

@@ -293,3 +280,3 @@

// Apply "two-digit-year" plugin to `date-and-time`.
// Apply the "two_digit_year" plugin to the library.
date.plugin(two_digit_year);

@@ -296,0 +283,0 @@

@@ -5,7 +5,7 @@ # date-and-time

This library is a minimalist collection of functions for manipulating JS date and time. It's tiny, simple, easy to learn.
This JS library is just a collection of functions for manipulating date and time. It's small, simple, and easy to learn.
## Why
JS modules nowadays are getting more huge and complex, and there are also many dependencies. Trying to keep each module simple and small is meaningful.
Nowadays, JS modules have become huge, complex, and have many dependencies. We think it makes sense to try to keep each module simple and small. Especially for modules that are at the bottom of the dependency chain, such as those dealing with date and time.

@@ -22,16 +22,13 @@ ## Features

- via npm:
```shell
npm install date-and-time --save
npm i date-and-time
```
- local:
## Recent Changes
```html
<script src="/path/to/date-and-time.min.js"></script>
```
- 1.0.0
- **First stable release!**
- ES Modules support.
- Added Kinyarwanda support.
## Recent Changes
- 0.14.2

@@ -43,24 +40,12 @@ - Fixed regular expression denial of service (ReDoS) vulnerability.

- 0.14.0
- **Feature Freeze**
## Usage
We decided to freeze the feature with this version (except the following). The next will be 1.0.0.
- ES Modules:
- To support `ES Modules` (without transpile) in the next version, the importing method has changed in the `locale()` and the `plugin()`. As this version you will see the warning message if using the old method. See [LOCALE.md](./LOCALE.md) and [PLUGINS.md](./PLUGINS.md) for details.
```javascript
import date from 'date-and-time';
```
- Added `transform()` function to transform the format of a date string. When changing the format, previously you would convert the date string to a date object with the `parse()`, and then format it with the `format()` again, but you can now do this with a single function.
- CommonJS:
```javascript
// 3/8/2020 => 8/3/2020
date.transform('3/8/2020', 'D/M/YYYY', 'M/D/YYYY');
// previously
const today = date.parse('3/8/2020', 'D/M/YYYY');
date.format(today, 'M/D/YYYY'); // => '8/3/2020'
```
## Usage
- Node.js:
```javascript

@@ -70,23 +55,85 @@ const date = require('date-and-time');

- With a transpiler:
- ES Modules for the browser:
```javascript
import date from 'date-and-time';
```html
<script type="module">
import date from '/path/to/date-and-time.es.min.js';
</script>
```
- The browser:
- Older browser:
```javascript
window.date; // global object
```html
<script src="/path/to/date-and-time.min.js"></script>
```
### NOTE
- 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`.
## API
- [format](#formatdateObj-formatString-utc)
- Formatting a Date and Time (Date -> String)
- [parse](#parsedateString-arg-utc)
- Parsing a Date and Time string (String -> Date)
- [compile](#compileformatString)
- Compiling a format string
- [preparse](#preparsedateString-arg)
- Pre-parsing a Date and Time string
- [isValid](#isValidarg1-arg2)
- Validation
- [transform](#transformdateString-arg1-arg2-utc)
- Transforming a Date and Time string (String -> String)
- [addYears](#addYearsdateObj-years)
- Adding years
- [addMonths](#addMonthsdateObj-months)
- Adding months
- [addDays](#addDaysdateObj-days)
- Adding days
- [addHours](#addHoursdateObj-hours)
- Adding hours
- [addMinutes](#addMinutesdateObj-minutes)
- Adding minutes
- [addSeconds](#addSecondsdateObj-seconds)
- Adding seconds
- [addMilliseconds](#addMillisecondsdateObj-milliseconds)
- Adding milliseconds
- [subtract](#subtractdate1-date2)
- Subtracting two dates
- [isLeapYear](#isLeapYeary)
- Whether year is leap year
- [isSameDay](#isSameDaydate1-date2)
- Comparison of two dates
- [locale](#localecode-locale)
- Changing the locale or defining new locales
- [extend](#extendextension)
- Feature extension
- [plugin](#pluginname-plugin)
- Importing or defining plugins
### format(dateObj, formatString[, utc])
- Formatting a date.
- @param {**Date**} dateObj - a Date object
- @param {**string|Array.\<string\>**} arg - a format string or a compiled object
- @param {**boolean**} [utc] - output as UTC
- @returns {**string**} a formatted string
- @param {**Date**} dateObj - a Date object
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
- @param {**boolean**} [utc] - output as UTC
- @returns {**string**} a formatted string

@@ -167,7 +214,6 @@ ```javascript

- Parsing a date string.
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg - a format string or a compiled object
- @param {**boolean**} [utc] - input as UTC
- @returns {**Date**} a constructed date
- @param {string} dateString - a date string
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
- @param {**boolean**} [utc] - input as UTC
- @returns {**Date**} a constructed date

@@ -297,3 +343,3 @@ ```javascript

The parser supports `...` (ellipse) token. The above example can also be written like this:
The parser supports `...` (ellipse) token. The above example can be also written like this:

@@ -306,6 +352,7 @@ ```javascript

- Compiling a format string for the parser.
- @param {**string**} formatString - a format string
- @returns {**Array.\<string\>**} a compiled object
- @param {**string**} formatString - a format string
- @returns {**Array.\<string\>**} a compiled object
If you are going to execute the `format()`, the `parse()` or the `isValid()` so many times with one string format, recommended to precompile and reuse it for performance.
```javascript

@@ -321,10 +368,7 @@ const pattern = date.compile('MMM D YYYY h:m:s A');

If you are going to call the `format()`, the `parse()` or the `isValid()` many times with one string format, recommended to precompile and reuse it for performance.
### preparse(dateString, arg)
- Pre-parsing a date string.
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg - a format string or a compiled object
- @returns {**Object**} a date structure
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg - a format string or its compiled object
- @returns {**Object**} a date structure

@@ -357,6 +401,5 @@ This function takes exactly the same parameters with the `parse()`, but returns a date structure as follows unlike that:

- Validation.
- @param {**Object|string**} arg1 - a date structure or a date string
- @param {**string|Array.\<string\>**} [arg2] - a format string or a compiled object
- @returns {**boolean**} whether the date string is a valid date
- @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

@@ -377,8 +420,7 @@ This function takes either exactly the same parameters with the `parse()` or a date structure which the `preparse()` returns, evaluates the validity of them.

- Transformation of date string.
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg1 - the format string of the date string or the compiled object
- @param {**string|Array.\<string\>**} arg2 - the transformed format string or the compiled object
- @param {**boolean**} [utc] - output as UTC
- @returns {**string**} a formatted string
- @param {**string**} dateString - a date string
- @param {**string|Array.\<string\>**} arg1 - a format string or its compiled object
- @param {**string|Array.\<string\>**} arg2 - a transformed format string or its compiled object
- @param {**boolean**} [utc] - output as UTC
- @returns {**string**} a formatted string

@@ -397,6 +439,5 @@ This function transforms the format of a date string. The 2nd parameter, `arg1`, is the format string of it. Available token list is equal to the `parse()`'s. The 3rd parameter, `arg2`, is the transformed format string. Available token list is equal to the `format()`'s.

- Adding years.
- @param {**Date**} dateObj - a Date object
- @param {**number**} years - number of years to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} years - number of years to add
- @returns {**Date**} a date after adding the value

@@ -410,6 +451,5 @@ ```javascript

- Adding months.
- @param {**Date**} dateObj - a Date object
- @param {**number**} months - number of months to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} months - number of months to add
- @returns {**Date**} a date after adding the value

@@ -423,6 +463,5 @@ ```javascript

- Adding days.
- @param {**Date**} dateObj - a Date object
- @param {**number**} days - number of days to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} days - number of days to add
- @returns {**Date**} a date after adding the value

@@ -436,6 +475,5 @@ ```javascript

- Adding hours.
- @param {**Date**} dateObj - a Date object
- @param {**number**} hours - number of hours to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} hours - number of hours to add
- @returns {**Date**} a date after adding the value

@@ -449,6 +487,5 @@ ```javascript

- Adding minutes.
- @param {**Date**} dateObj - a Date object
- @param {**number**} minutes - number of minutes to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} minutes - number of minutes to add
- @returns {**Date**} a date after adding the value

@@ -462,6 +499,5 @@ ```javascript

- Adding seconds.
- @param {**Date**} dateObj - a Date object
- @param {**number**} seconds - number of seconds to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} seconds - number of seconds to add
- @returns {**Date**} a date after adding the value

@@ -475,6 +511,5 @@ ```javascript

- Adding milliseconds.
- @param {**Date**} dateObj - a Date object
- @param {**number**} milliseconds - number of milliseconds to add
- @returns {**Date**} a date after adding the value
- @param {**Date**} dateObj - a Date object
- @param {**number**} milliseconds - number of milliseconds to add
- @returns {**Date**} a date after adding the value

@@ -488,6 +523,5 @@ ```javascript

- Subtracting.
- @param {**Date**} date1 - a Date object
- @param {**Date**} date2 - a Date object
- @returns {**Object**} a result object subtracting date2 from date1
- @param {**Date**} date1 - a Date object
- @param {**Date**} date2 - a Date object
- @returns {**Object**} a result object subtracting date2 from date1

@@ -507,5 +541,4 @@ ```javascript

- Leap year.
- @param {**number**} y - year
- @returns {**boolean**} whether the year is a leap year
- @param {**number**} y - year
- @returns {**boolean**} whether year is leap year

@@ -519,6 +552,5 @@ ```javascript

- Comparison of two dates.
- @param {**Date**} date1 - a Date object
- @param {**Date**} date2 - a Date object
- @returns {**boolean**} whether the dates are the same day (times are ignored)
- @param {**Date**} date1 - a Date object
- @param {**Date**} date2 - a Date object
- @returns {**boolean**} whether the two dates are the same day (time is ignored)

@@ -535,8 +567,7 @@ ```javascript

- Change locale or setting a new locale definition.
- @param {**string**} [code] - language code
- @param {**Object**} [locale] - locale definition
- @returns {**string**} current language code
- @param {**Function|string**} [code] - locale installer | language code
- @param {**Object**} [locale] - locale definition
- @returns {**string**} current language code
It returns a current language code if called without any parameters.
It returns the current language code if called without any parameters.

@@ -547,6 +578,8 @@ ```javascript

To switch to any other language, call it with a language code.
To switch to any other language, call it with a locale installer or a language code.
```javascript
date.locale('es'); // Switch to Spanish
import es from 'date-and-time/locale/es';
date.locale(es); // Switch to Spanish
```

@@ -558,16 +591,14 @@

- Locale extension.
- @param {**Object**} extension - locale definition
- @returns {**void**}
- @param {**Object**} extension - extension object
- @returns {**void**}
Extend a current locale. See [EXTEND.md](./EXTEND.md) for details.
It extends the formatter and the parser of the current locale. See [EXTEND.md](./EXTEND.md) for details.
### plugin(name[, extension])
### plugin(name[, plugin])
- Plugin import or definition.
- @param {**string**} name - plugin name
- @param {**Object**} [extension] - locale definition
- @returns {**void**}
- @param {**Function|string**} name - plugin installer | plugin name
- @param {**Object**} [plugin] - plugin object
- @returns {**void**}
Plugin is a named locale definition defined with the `extend()`. See [PLUGINS.md](./PLUGINS.md) for details.
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.

@@ -574,0 +605,0 @@ ## Browser Support

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc