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.13.1 to 0.14.0

locale/en.js

36

date-and-time.js

@@ -245,2 +245,14 @@ /**

/**
* 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
*/
date.transform = function (dateString, arg1, arg2, utc) {
return date.format(date.parse(dateString, arg1), arg2, utc);
};
/**
* adding years

@@ -370,3 +382,3 @@ * @param {Date} dateObj - a date object

* change locale or setting a new locale definition
* @param {string} [code] - language code
* @param {Function|string} [code] - locale function | language code
* @param {Object} [locale] - locale definition

@@ -378,3 +390,8 @@ * @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;

@@ -405,10 +422,17 @@ }

* plugin import or definition
* @param {string} name - plugin name
* @param {Function|string} plugin - plugin function | plugin name
* @param {Object} [extension] - locale extension
* @returns {void}
*/
date.plugin = function (name, extension) {
plugins[name] = plugins[name] || extension;
if (!extension && plugins[name]) {
date.extend(plugins[name]);
date.plugin = function (plugin, extension) {
if (typeof plugin === 'function') {
date.extend(plugins[plugin(date)]);
} 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.');
}
}
}

@@ -415,0 +439,0 @@ };

19

date-and-time.min.js
/*
date-and-time.js (c) KNOWLEDGECODE | MIT
*/
(function(r){var d={},n={},m={},l="en",t={MMMM:"January February March April May June July August September October November December".split(" "),MMM:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),dddd:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),ddd:"Sun Mon Tue Wed Thu Fri Sat".split(" "),dd:"Su Mo Tu We Th Fr Sa".split(" "),A:["AM","PM"]},u={YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)},Y:function(a){return""+
(function(p){var d={},r={},q={},l="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}},v={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/,
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,d=0,f=0,h=a.length,g;f<h;f++)g=a[f],!c.indexOf(g)&&g.length>d&&(b=f,d=g.length);return{value:b,length:d}},pre:function(a){return a}},q=function(a,
c,b){var d=function(a,b,c){var d=function(a){a&&(this.res=a)};d.prototype=a;d.prototype.constructor=d;a=new d(c);for(var e in b||{})c=b[e],a[e]=c.slice?c.slice():c;return a},f={res:d(c.res,b.res)};f.formatter=d(c.formatter,b.formatter,f.res);f.parser=d(c.parser,b.parser,f.res);n[a]=f};d.compile=function(a){for(var c=/\[([^\[\]]*|\[[^\[\]]*\])*\]|([A-Za-z])\2+|\.{3}|./g,b,d=[a];b=c.exec(a);)d[d.length]=b[0];return d};d.format=function(a,c,b){c="string"===typeof c?d.compile(c):c;a=d.addMinutes(a,b?
a.getTimezoneOffset():0);var e=n[l].formatter,f="";a.utc=b||!1;b=1;for(var h=c.length,g;b<h;b++)g=c[b],f+=e[g]?e.post(e[g](a,c[0])):g.replace(/\[(.*)]/,"$1");return f};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},f=n[l].parser,h=0;a=f.pre(a);for(var g=1,m=b.length,k,p;g<m;g++)if(k=b[g],f[k]){p=f[k](a.slice(h),b[0]);if(!p.length)break;h+=p.length;e[k.charAt(0)]=p.value;e._match++}else if(k===a.charAt(h)||
" "===k)h++;else if(/\[.*]/.test(k))h+=k.length-2;else{"..."===k&&(h=a.length);break}e.H=e.H||f.h12(e.h,e.A);e._index=h;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.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?q(a,{res:t,formatter:u,parser:v},c):a&&(l=a);return l};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)&&q(l,n[l],a)};d.plugin=function(a,c){m[a]=m[a]||c;!c&&m[a]&&d.extend(m[a])};d.locale(l,{});"object"===typeof module&&"object"===typeof module.exports?module.exports=d:"function"===typeof define&&define.amd?define([],function(){return d}):r.date=d})(this);
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,f=0,g=a.length,h;f<g;f++)h=a[f],!c.indexOf(h)&&h.length>e&&(b=f,e=h.length);return{value:b,length:e}},pre:function(a){return a}},u=function(a,
c,b){var e=function(g,h,m){var k=function(t){t&&(this.res=t)};k.prototype=g;k.prototype.constructor=k;g=new k(m);for(var n in h||{})m=h[n],g[n]=m.slice?m.slice():m;return g},f={res:e(c.res,b.res)};f.formatter=e(c.formatter,b.formatter,f.res);f.parser=e(c.parser,b.parser,f.res);r[a]=f};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=r[l].formatter,f="";a.utc=b||!1;b=1;for(var g=c.length,h;b<g;b++)h=c[b],f+=e[h]?e.post(e[h](a,c[0])):h.replace(/\[(.*)]/,"$1");return f};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},f=r[l].parser,g=0;a=f.pre(a);for(var h=1,m=b.length,k,n;h<m;h++)if(k=b[h],f[k]){n=f[k](a.slice(g),b[0]);if(!n.length)break;g+=n.length;e[k.charAt(0)]=n.value;e._match++}else if(k===a.charAt(g)||
" "===k)g++;else if(/\[.*]/.test(k))g+=k.length-2;else{"..."===k&&(g=a.length);break}e.H=e.H||f.h12(e.h,e.A);e._index=g;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?l=a(d):a&&(p&&!p.date&&console.warn("This method of changing the locale is deprecated. See documentation for details."),l=a);return l};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(l,r[l],a)};d.plugin=function(a,c){"function"===typeof a?d.extend(q[a(d)]):(q[a]=q[a]||c,!c&&q[a]&&(d.extend(q[a]),p&&!p.date&&console.warn("This method of applying plugins is deprecated. See documentation for details.")))};
d.locale(l,{});"object"===typeof module&&"object"===typeof module.exports?module.exports=d:"function"===typeof define&&define.amd?define([],function(){return d}):p.date=d})(this);
# Locale
Month, day of week, and meridiem (am / pm) the `format()` outputs are usually in English, and the `parse()` also assumes that a passed date string is English.
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.
## Usage
If you would like to use any other language in these functions, switch as follows:
To support `ES Modules` in the next version, the locale switching method has changed and then the old method has been deprecated.
- Node.js:
- CommonJS:
```javascript
const date = require('date-and-time');
require('date-and-time/locale/fr');
const fr = require('date-and-time/locale/fr');
date.locale('fr'); // French
date.locale(fr); // French
date.format(new Date(), 'dddd D MMMM'); // => 'lundi 11 janvier'
```
- With a transpiler:
- ES Modules (with transpile):
```javascript
import date from 'date-and-time';
import 'date-and-time/locale/it';
import it from 'date-and-time/locale/it';
date.locale('it'); // Italian
date.locale(it); // Italian
date.format(new Date(), 'dddd D MMMM'); // => 'Lunedì 11 gennaio'
```
- With an older browser:
- Older browser:
When in older browser, pass the locale string as before. (no changes)
```html

@@ -36,3 +38,3 @@ <script src="/path/to/date-and-time.min.js"></script>

<script>
date.locale('zh-cn'); // Chinese
date.locale('zh-cn'); // Chinese
date.format(new Date(), 'MMMD日dddd'); // => '1月11日星期一'

@@ -45,9 +47,39 @@ </script>

- You have to import (or require) in advance the all locale modules that you are going to switch to.
- The locale will be actually switched after executing `locale('xx')`.
- You could return the locale to English by executing `locale ('en')`.
- The locale will be actually switched after executing the `locale()`.
- You can also change the locale back to English by loading the `en` module:
## Supported List
```javascript
import en from 'date-and-time/locale/en';
For now, it supports the following languages:
date.locale(en);
```
### 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
At this time, it supports the following locales:
```text

@@ -54,0 +86,0 @@ Arabic (ar)

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

var exec = function (date) {
date.locale('ar', {
var code = 'ar';
date.locale(code, {
res: {

@@ -37,2 +39,3 @@ MMMM: ['كانون الثاني يناير', 'شباط فبراير', 'آذار مارس', 'نيسان أبريل', 'أيار مايو', 'حزيران يونيو', 'تموز يوليو', 'آب أغسطس', 'أيلول سبتمبر', 'تشرين الأول أكتوبر', 'تشرين الثاني نوفمبر', 'كانون الأول ديسمبر'],

});
return code;
};

@@ -42,2 +45,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -44,0 +49,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('az', {
var code = 'az';
date.locale(code, {
res: {

@@ -42,2 +44,3 @@ MMMM: ['yanvar', 'fevral', 'mart', 'aprel', 'may', 'iyun', 'iyul', 'avqust', 'sentyabr', 'oktyabr', 'noyabr', 'dekabr'],

});
return code;
};

@@ -47,2 +50,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -49,0 +54,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('bn', {
var code = 'bn';
date.locale(code, {
res: {

@@ -48,2 +50,3 @@ MMMM: ['জানুয়ারী', 'ফেবুয়ারী', 'মার্চ', 'এপ্রিল', 'মে', 'জুন', 'জুলাই', 'অগাস্ট', 'সেপ্টেম্বর', 'অক্টোবর', 'নভেম্বর', 'ডিসেম্বর'],

});
return code;
};

@@ -53,2 +56,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -55,0 +60,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('cs', {
var code = 'cs';
date.locale(code, {
res: {

@@ -20,2 +22,3 @@ MMMM: ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec'],

});
return code;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -10,2 +10,4 @@ /**

var exec = function (date) {
var code = 'de';
date.locale('de', {

@@ -21,2 +23,3 @@ res: {

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -10,2 +10,4 @@ /**

var exec = function (date) {
var code = 'dk';
date.locale('dk', {

@@ -20,2 +22,3 @@ res: {

});
return code;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -10,2 +10,4 @@ /**

var exec = function (date) {
var code = 'el';
date.locale('el', {

@@ -40,2 +42,3 @@ res: {

});
return code;
};

@@ -45,2 +48,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -47,0 +52,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('es', {
var code = 'es';
date.locale(code, {
res: {

@@ -40,2 +42,3 @@ MMMM: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],

});
return code;
};

@@ -45,2 +48,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -47,0 +52,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('fa', {
var code = 'fa';
date.locale(code, {
res: {

@@ -37,2 +39,3 @@ MMMM: ['ژانویه', 'فوریه', 'مارس', 'آوریل', 'مه', 'ژوئن', 'ژوئیه', 'اوت', 'سپتامبر', 'اکتبر', 'نوامبر', 'دسامبر'],

});
return code;
};

@@ -42,2 +45,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -44,0 +49,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('fr', {
var code = 'fr';
date.locale(code, {
res: {

@@ -21,2 +23,3 @@ MMMM: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('hi', {
var code = 'hi';
date.locale(code, {
res: {

@@ -48,2 +50,3 @@ MMMM: ['जनवरी', 'फ़रवरी', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अगस्त', 'सितम्बर', 'अक्टूबर', 'नवम्बर', 'दिसम्बर'],

});
return code;
};

@@ -53,2 +56,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -55,0 +60,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('hu', {
var code = 'hu';
date.locale(code, {
res: {

@@ -21,2 +23,3 @@ MMMM: ['január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december'],

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('id', {
var code = 'id';
date.locale(code, {
res: {

@@ -44,2 +46,3 @@ MMMM: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'],

});
return code;
};

@@ -49,2 +52,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -51,0 +56,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('it', {
var code = 'it';
date.locale(code, {
res: {

@@ -21,2 +23,3 @@ MMMM: ['gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre'],

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('ja', {
var code = 'ja';
date.locale(code, {
res: {

@@ -29,2 +31,3 @@ MMMM: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],

});
return code;
};

@@ -34,2 +37,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -36,0 +41,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('jv', {
var code = 'jv';
date.locale(code, {
res: {

@@ -44,2 +46,3 @@ MMMM: ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'Nopember', 'Desember'],

});
return code;
};

@@ -49,2 +52,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -51,0 +56,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('ko', {
var code = 'ko';
date.locale(code, {
res: {

@@ -21,2 +23,3 @@ MMMM: ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월'],

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('my', {
var code = 'my';
date.locale(code, {
res: {

@@ -36,2 +38,3 @@ MMMM: ['ဇန်နဝါရီ', 'ဖေဖော်ဝါရီ', 'မတ်', 'ဧပြီ', 'မေ', 'ဇွန်', 'ဇူလိုင်', 'သြဂုတ်', 'စက်တင်ဘာ', 'အောက်တိုဘာ', 'နိုဝင်ဘာ', 'ဒီဇင်ဘာ'],

});
return code;
};

@@ -41,2 +44,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -43,0 +48,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('nl', {
var code = 'nl';
date.locale(code, {
res: {

@@ -33,2 +35,3 @@ MMMM: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],

});
return code;
};

@@ -38,2 +41,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -40,0 +45,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('pa-in', {
var code = 'pa-in';
date.locale(code, {
res: {

@@ -60,2 +62,3 @@ MMMM: ['ਜਨਵਰੀ', 'ਫ਼ਰਵਰੀ', 'ਮਾਰਚ', 'ਅਪ੍ਰੈਲ', 'ਮਈ', 'ਜੂਨ', 'ਜੁਲਾਈ', 'ਅਗਸਤ', 'ਸਤੰਬਰ', 'ਅਕਤੂਬਰ', 'ਨਵੰਬਰ', 'ਦਸੰਬਰ'],

});
return code;
};

@@ -65,2 +68,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -67,0 +72,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('pl', {
var code = 'pl';
date.locale(code, {
res: {

@@ -33,2 +35,3 @@ MMMM_nominative: ['styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec', 'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień'],

});
return code;
};

@@ -38,2 +41,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -40,0 +45,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('pt', {
var code = 'pt';
date.locale(code, {
res: {

@@ -42,2 +44,3 @@ MMMM: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],

});
return code;
};

@@ -47,2 +50,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -49,0 +54,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -10,2 +10,4 @@ /**

var exec = function (date) {
var code = 'ro';
date.locale('ro', {

@@ -20,2 +22,3 @@ res: {

});
return code;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('ru', {
var code = 'ru';
date.locale(code, {
res: {

@@ -42,2 +44,3 @@ MMMM: ['Января', 'Февраля', 'Марта', 'Апреля', 'Мая', 'Июня', 'Июля', 'Августа', 'Сентября', 'Октября', 'Ноября', 'Декабря'],

});
return code;
};

@@ -47,2 +50,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -49,0 +54,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('sr', {
var code = 'sr';
date.locale(code, {
res: {

@@ -20,2 +22,3 @@ MMMM: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],

});
return code;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('th', {
var code = 'th';
date.locale(code, {
res: {

@@ -21,2 +23,3 @@ MMMM: ['มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'],

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('tr', {
var code = 'tr';
date.locale(code, {
res: {

@@ -20,2 +22,3 @@ MMMM: ['Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık'],

});
return code;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('uk', {
var code = 'uk';
date.locale(code, {
res: {

@@ -53,2 +55,3 @@ MMMM: ['січня', 'лютого', 'березня', 'квітня', 'травня', 'червня', 'липня', 'серпня', 'вересня', 'жовтня', 'листопада', 'грудня'],

});
return code;
};

@@ -58,2 +61,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -60,0 +65,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('uz', {
var code = 'uz';
date.locale(code, {
res: {

@@ -20,2 +22,3 @@ MMMM: ['январ', 'феврал', 'март', 'апрел', 'май', 'июн', 'июл', 'август', 'сентябр', 'октябр', 'ноябр', 'декабр'],

});
return code;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('vi', {
var code = 'vi';
date.locale(code, {
res: {

@@ -21,2 +23,3 @@ MMMM: ['tháng 1', 'tháng 2', 'tháng 3', 'tháng 4', 'tháng 5', 'tháng 6', 'tháng 7', 'tháng 8', 'tháng 9', 'tháng 10', 'tháng 11', 'tháng 12'],

});
return code;
};

@@ -26,2 +29,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -28,0 +33,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('zh-cn', {
var code = 'zh-cn';
date.locale(code, {
res: {

@@ -46,2 +48,3 @@ MMMM: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],

});
return code;
};

@@ -51,2 +54,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -53,0 +58,0 @@ } else if (typeof define === 'function' && define.amd) {

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

var exec = function (date) {
date.locale('zh-tw', {
var code = 'zh-tw';
date.locale(code, {
res: {

@@ -44,2 +46,3 @@ MMMM: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],

});
return code;
};

@@ -49,2 +52,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -51,0 +56,0 @@ } else if (typeof define === 'function' && define.amd) {

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

@@ -5,0 +5,0 @@ "main": "date-and-time.js",

@@ -5,3 +5,5 @@ (function (global) {

var exec = function (date) {
date.plugin('day-of-week', {
var name = 'day-of-week';
date.plugin(name, {
parser: {

@@ -13,2 +15,3 @@ dddd: function (str) { return this.find(this.res.dddd, str); },

});
return name;
};

@@ -18,2 +21,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -20,0 +25,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -5,3 +5,5 @@ (function (global) {

var exec = function (date) {
date.plugin('meridiem', {
var name = 'meridiem';
date.plugin(name, {
res: {

@@ -32,2 +34,3 @@ A: ['AM', 'PM', 'A.M.', 'P.M.', 'am', 'pm', 'a.m.', 'p.m.']

});
return name;
};

@@ -37,2 +40,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -39,0 +44,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -5,2 +5,4 @@ (function (global) {

var exec = function (date) {
var name = 'microsecond';
date.plugin('microsecond', {

@@ -25,2 +27,3 @@ parser: {

});
return name;
};

@@ -30,2 +33,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -32,0 +37,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -5,3 +5,5 @@ (function (global) {

var exec = function (date) {
date.plugin('ordinal', {
var name = 'ordinal';
date.plugin(name, {
formatter: {

@@ -28,2 +30,3 @@ DDD: function (d) {

});
return name;
};

@@ -33,2 +36,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -35,0 +40,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -67,4 +67,6 @@ (function (global) {

};
var name = 'timespan';
date.plugin('timespan', { extender: { timeSpan: timeSpan } });
date.plugin(name, { extender: { timeSpan: timeSpan } });
return name;
};

@@ -74,2 +76,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -76,0 +80,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -5,3 +5,5 @@ (function (global) {

var exec = function (date) {
date.plugin('two-digit-year', {
var name = 'two-digit-year';
date.plugin(name, {
parser: {

@@ -20,2 +22,3 @@ YY: function (str) {

});
return name;
};

@@ -25,2 +28,4 @@

(module.paths || []).push('./');
module.exports = exec;
// This line will be removed in the next version.
exec(require('date-and-time'));

@@ -27,0 +32,0 @@ } else if (typeof define === 'function' && define.amd) {

@@ -7,29 +7,33 @@ # Plugins

- Node.js:
To support `ES Modules` in the next version, the importing method has changed and then the old method has been deprecated.
- CommonJS:
```javascript
const date = require('date-and-time');
// Import a plugin "foobar".
require('date-and-time/plugin/foobar');
// Import the plugin "foobar".
const foobar = require('date-and-time/plugin/foobar');
// Apply the plugin to "date-and-time".
date.plugin('foobar');
date.plugin(foobar);
```
- With a transpiler:
- ES Modules (with transpile):
```javascript
import date from 'date-and-time';
// Import a plugin "foobar".
import 'date-and-time/plugin/foobar';
// Import the plugin "foobar".
import foobar from 'date-and-time/plugin/foobar';
// Apply the plugin to "date-and-time".
date.plugin('foobar');
date.plugin(foobar);
```
- The browser:
- Older browser:
When in older browser, pass the plugin name as before. (no changes)
```html
<script src="/path/to/date-and-time.min.js"></script>
<!-- Import a plugin "foobar". -->
<!-- Import the plugin "foobar". -->
<script src="/path/to/plugin/foobar.js"></script>

@@ -43,2 +47,28 @@

### 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');
// 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

@@ -79,6 +109,6 @@

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

@@ -112,6 +142,6 @@ // You can write like this.

// Import "meridiem" plugin.
require('date-and-time/plugin/meridiem');
const meridiem = require('date-and-time/plugin/meridiem');
// Apply "medidiem" plugin to `date-and-time`.
date.plugin('meridiem');
date.plugin(meridiem);

@@ -149,6 +179,6 @@ // This is default behavior of the formatter.

// Import "microsecond" plugin.
require('date-and-time/plugin/microsecond');
const microsecond = require('date-and-time/plugin/microsecond');
// Apply "microsecond" plugin to `date-and-time`.
date.plugin('microsecond');
date.plugin(microsecond);

@@ -177,6 +207,6 @@ // A date object in JavaScript supports `millisecond` (ms):

// Import "ordinal" plugin.
require('date-and-time/plugin/ordinal');
const ordinal = require('date-and-time/plugin/ordinal');
// Apply "ordinal" plugin to `date-and-time`.
date.plugin('ordinal');
date.plugin(ordinal);

@@ -198,6 +228,6 @@ // These are default behavior of the formatter.

// Import "timespan" plugin.
require('date-and-time/plugin/timespan');
const timespan = require('date-and-time/plugin/timespan');
// Apply "timespan" plugin to `date-and-time`.
date.plugin('timespan');
date.plugin(timespan);

@@ -255,3 +285,3 @@ const now = new Date(2020, 2, 5, 1, 2, 3, 4);

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

@@ -263,3 +293,3 @@ // These are default behavior of the parser.

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

@@ -266,0 +296,0 @@ // These convert the year 69 or earlier to 2000s, the year 70 or later to 1900s.

@@ -35,2 +35,20 @@ # date-and-time

- 0.14.0
- **Feature Freeze**
We decided to freeze the feature with this version (except the following). The next will be 1.0.0.
- 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.
- Added `transform()` function to transform the format of a date string. When changing the format, in the past 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.
```javascript
// 3/8/2020 => 8/3/2020
date.transform('3/8/2020', 'D/M/YYYY', 'M/D/YYYY');
// in the past
const today = date.parse('3/8/2020', 'D/M/YYYY');
date.format(today, 'M/D/YYYY'); // => '8/3/2020'
```
- 0.13.0

@@ -103,27 +121,2 @@ - The `format()` now supports a compiled formatString.

- 0.11.0
- Added `compile()` function that precompiling a date-time string for the parser. If you need to process many date-time string with one format, you can get results faster than before by precompiling the format string with this function.
```javascript
// We have passed a string format at the 2nd parameter each time when calling the parse() function.
date.parse('Mar 22 2019 2:54:21 PM', 'MMM D YYYY h:m:s A');
date.parse('Jul 27 2019 4:15:24 AM', 'MMM D YYYY h:m:s A');
date.parse('Dec 25 2019 3:51:11 AM', 'MMM D YYYY h:m:s A');
// You can precompile the string format.
const pattern = date.compile('MMM D YYYY h:m:s A');
// The parse() will be able to finish faster than passing the format string each time.
date.parse('Mar 22 2019 2:54:21 PM', pattern);
date.parse('Jul 27 2019 4:15:24 AM', pattern);
date.parse('Dec 25 2019 3:51:11 AM', pattern);
```
```javascript
const pattern = date.compile('MMM D YYYY h:m:s A');
// The isValid() will also too.
date.isValid('Mar 22 2019 2:54:21 PM', pattern);
```
## Usage

@@ -436,2 +429,21 @@

### transform(dateString, arg1, arg2[, utc])
- 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
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.
```javascript
// 3/8/2020 => 8/3/2020
date.transform('3/8/2020', 'D/M/YYYY', 'M/D/YYYY');
// 13:05 => 01:05 PM
date.transform('13:05', 'HH:mm', 'hh:mm A');
```
### addYears(dateObj, years)

@@ -438,0 +450,0 @@

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