Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

date-and-time

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-and-time - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

40

date-and-time.js

@@ -19,24 +19,22 @@ /**

YYYY: function (d) { return ('000' + d.getFullYear()).slice(-4); },
YY: function (d) { return this.formats.YYYY(d).slice(2); },
YY: function (d) { return ('0' + d.getFullYear()).slice(-2); },
Y: function (d) { return '' + d.getFullYear(); },
MMMM: function (d) { return this.MMMM[d.getMonth()]; },
MMM: function (d) { return this.MMM[d.getMonth()]; },
MM: function (d) { return ('0' + (d.getMonth() + 1)).slice(-2); },
M: function (d) { return '' + (d.getMonth() + 1); },
MM: function (d) { return ('0' + this.formats.M(d)).slice(-2); },
DD: function (d) { return ('0' + d.getDate()).slice(-2); },
D: function (d) { return '' + d.getDate(); },
DD: function (d) { return ('0' + this.formats.D(d)).slice(-2); },
HH: function (d) { return ('0' + d.getHours()).slice(-2); },
H: function (d) { return '' + d.getHours(); },
HH: function (d) { return ('0' + this.formats.H(d)).slice(-2); },
h: function (d) {
var h = d.getHours() || 12;
return '' + (h > 12 ? h - 12 : h);
},
hh: function (d) { return ('0' + this.formats.h(d)).slice(-2); },
A: function (d) { return this.A[d.getHours() > 11 | 0]; },
hh: function (d) { return ('0' + (d.getHours() % 12 || 12)).slice(-2); },
h: function (d) { return '' + (d.getHours() % 12 || 12); },
mm: function (d) { return ('0' + d.getMinutes()).slice(-2); },
m: function (d) { return '' + d.getMinutes(); },
mm: function (d) { return ('0' + this.formats.m(d)).slice(-2); },
ss: function (d) { return ('0' + d.getSeconds()).slice(-2); },
s: function (d) { return '' + d.getSeconds(); },
ss: function (d) { return ('0' + this.formats.s(d)).slice(-2); },
SSS: function (d) { return ('00' + d.getMilliseconds()).slice(-3); },
SS: function (d) { return this.formats.SSS(d).slice(0, 2); },
S: function (d) { return this.formats.SSS(d).slice(0, 1); },
SS: function (d) { return ('0' + (d.getMilliseconds() / 10 | 0)).slice(-2); },
S: function (d) { return '' + (d.getMilliseconds() / 100 | 0); },
dddd: function (d) { return this.dddd[d.getDay()]; },

@@ -46,18 +44,10 @@ ddd: function (d) { return this.ddd[d.getDay()]; },

Z: function (d) {
var offset = d.utc ? 0 : d.getTimezoneOffset(), sign = '-';
if (offset <= 0) {
sign = '+';
offset = -offset;
}
return sign + ('000' + ((offset / 60 | 0) * 100 + offset % 60)).slice(-4);
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;
}
post: function (str) { return str; }
},
parsers: {
h: function (h, a) { return (h === 12 ? 0 : h) + a * 12; },
pre: function (str) {
return str;
}
pre: function (str) { return str; }
}

@@ -64,0 +54,0 @@ }

/*
date-and-time.js (c) KNOWLEDGECODE | MIT
*/
(function(p){var d={},h="en",g={en:{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:["a.m.","p.m."],formats:{YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return this.formats.YYYY(a).slice(2)},MMMM:function(a){return this.MMMM[a.getMonth()]},
MMM:function(a){return this.MMM[a.getMonth()]},M:function(a){return""+(a.getMonth()+1)},MM:function(a){return("0"+this.formats.M(a)).slice(-2)},D:function(a){return""+a.getDate()},DD:function(a){return("0"+this.formats.D(a)).slice(-2)},H:function(a){return""+a.getHours()},HH:function(a){return("0"+this.formats.H(a)).slice(-2)},h:function(a){a=a.getHours()||12;return""+(12<a?a-12:a)},hh:function(a){return("0"+this.formats.h(a)).slice(-2)},A:function(a){return this.A[11<a.getHours()|0]},m:function(a){return""+
a.getMinutes()},mm:function(a){return("0"+this.formats.m(a)).slice(-2)},s:function(a){return""+a.getSeconds()},ss:function(a){return("0"+this.formats.s(a)).slice(-2)},SSS:function(a){return("00"+a.getMilliseconds()).slice(-3)},SS:function(a){return this.formats.SSS(a).slice(0,2)},S:function(a){return this.formats.SSS(a).slice(0,1)},dddd:function(a){return this.dddd[a.getDay()]},ddd:function(a){return this.ddd[a.getDay()]},dd:function(a){return this.dd[a.getDay()]},Z:function(a){a=a.utc?0:a.getTimezoneOffset();
var c="-";0>=a&&(c="+",a=-a);return c+("000"+(100*(a/60|0)+a%60)).slice(-4)},post:function(a){return a}},parsers:{h:function(a,c){return(12===a?0:a)+12*c},pre:function(a){return a}}}},l=function(){return"object"===typeof module&&"object"===typeof module.exports},m=function(a,c){for(var b=0,d=a.length;b<d&&0!==c(a[b],b);b++);},n=function(a,c){var b=0,d,e,f,q=c.match(/YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|./g),k={Y:0,M:1,D:1,A:0,H:0,h:0,m:0,s:0,S:0};a=g[h].parsers.pre(a);m(q,function(c){d=c.charAt(0);
e=c.length;f=a.slice(b);/^(MM|DD|HH|hh|mm|ss|SS?S?)$/.test(c)?k[d]=f.slice(0,e)|0:/^(YYYY|YY|M|D|H|h|m|s)$/.test(c)?(f=(f.match(4===e?/^\d{1,4}/:/^\d\d?/)||[""])[0],e=f.length,k[d]=f|0,"Y"===d&&70>k.Y&&(k.Y+=2E3)):/^(MMMM?|A)$/.test(c)&&m(g[h][c],function(a,b){if(!f.indexOf(a))return k[d]="M"===d?b+1:b,e=a.length,0});b+=e});return k};d.format=function(a,c,b){var d=new Date(a.getTime()+(b?6E4*a.getTimezoneOffset():0)),e=g[h],f=e.formats;d.utc=b;return c.replace(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g,
(function(p){var d={},h="en",g={en:{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:["a.m.","p.m."],formats:{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.MMMM[a.getMonth()]},MMM:function(a){return this.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.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.dddd[a.getDay()]},ddd:function(a){return this.ddd[a.getDay()]},dd:function(a){return this.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}},parsers:{h:function(a,c){return(12===a?0:a)+12*c},pre:function(a){return a}}}},l=function(){return"object"===typeof module&&"object"===typeof module.exports},m=function(a,c){for(var b=0,d=a.length;b<d&&0!==c(a[b],b);b++);},n=function(a,c){var b=0,d,e,f,q=c.match(/YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|./g),k={Y:0,M:1,D:1,A:0,H:0,h:0,m:0,s:0,S:0};a=g[h].parsers.pre(a);
m(q,function(c){d=c.charAt(0);e=c.length;f=a.slice(b);/^(MM|DD|HH|hh|mm|ss|SS?S?)$/.test(c)?k[d]=f.slice(0,e)|0:/^(YYYY|YY|M|D|H|h|m|s)$/.test(c)?(f=(f.match(4===e?/^\d{1,4}/:/^\d\d?/)||[""])[0],e=f.length,k[d]=f|0,"Y"===d&&70>k.Y&&(k.Y+=2E3)):/^(MMMM?|A)$/.test(c)&&m(g[h][c],function(a,b){if(!f.indexOf(a))return k[d]="M"===d?b+1:b,e=a.length,0});b+=e});return k};d.format=function(a,c,b){var d=new Date(a.getTime()+(b?6E4*a.getTimezoneOffset():0)),e=g[h],f=e.formats;d.utc=b;return c.replace(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g,
function(a){var b=f[a];return b?f.post(b.call(e,d)):a.replace(/\[(.*)]/,"$1")})};d.parse=function(a,c,b){a=n(a,c);a=new Date(a.Y,a.M-1,a.D,a.H||g[h].parsers.h(a.h,a.A),a.m,a.s,a.S);return b?new Date(a.getTime()-6E4*a.getTimezoneOffset()):a};d.isValid=function(a,c){var b=n(a,c),d=b.H||g[h].parsers.h(b.h,b.A),e=new Date(b.Y,b.M-1,b.D,d,b.m,b.s,b.S);return b.Y===e.getFullYear()&&b.M-1===e.getMonth()&&b.D===e.getDate()&&d===e.getHours()&&b.m===e.getMinutes()&&b.s===e.getSeconds()&&b.S===e.getMilliseconds()};

@@ -10,0 +10,0 @@ d.addYears=function(a,c){var b=new Date(a.getTime());b.setFullYear(b.getFullYear()+c);return b};d.addMonths=function(a,c){var b=new Date(a.getTime());b.setMonth(b.getMonth()+c);return b};d.addDays=function(a,c){return new Date(a.getTime()+864E5*c)};d.addHours=function(a,c){return new Date(a.getTime()+36E5*c)};d.addMinutes=function(a,c){return new Date(a.getTime()+6E4*c)};d.addSeconds=function(a,c){return new Date(a.getTime()+1E3*c)};d.addMilliseconds=function(a,c){return new Date(a.getTime()+c)};

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

formats: {
hh: function (d) {
return ('0' + d.getHours() % 12).slice(-2);
},
h: function (d) {
var h = d.getHours();
return '' + (h > 11 ? h - 12 : h);
return d.getHours() % 12;
}

@@ -23,0 +25,0 @@ }

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

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

@@ -59,4 +59,5 @@ # date-and-time

|:-------------|:------------|:------------------|
| YYYY | year | 2015, 1999 |
| YYYY | year | 0999, 2015 |
| YY | year | 15, 99 |
| Y | year | 999, 2015 |
| MMMM | month | January, December |

@@ -63,0 +64,0 @@ | MMM | month | Jan, Dec |

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc