date-and-time
Advanced tools
Comparing version 0.6.1 to 0.6.2
@@ -289,3 +289,3 @@ /** | ||
if (code) { | ||
if (code !== 'en' && typeof require === 'function' && global) { | ||
if (!locales[code] && typeof require === 'function' && global) { | ||
require('./locale/' + code); | ||
@@ -292,0 +292,0 @@ } |
/* | ||
date-and-time.js (c) KNOWLEDGECODE | MIT | ||
*/ | ||
(function(p){var b={},n="en",l={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."],formatter:{YYYY:function(a){return("000"+a.getFullYear()).slice(-4)},YY:function(a){return("0"+a.getFullYear()).slice(-2)}, | ||
(function(p){var b={},n="en",k={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."],formatter:{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}},parser:{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{index:b,length:e}},MMMM:function(a){return this.parser.find(this.MMMM,a)},MMM:function(a){return this.parser.find(this.MMM,a)},A:function(a){return this.parser.find(this.A,a)},h:function(a,c){return(12===a?0:a)+12*c},pre:function(a){return a}}}}; | ||
b.format=function(a,c,q){var e=b.addMinutes(a,q?a.getTimezoneOffset():0),g=l[n],h=g.formatter;e.utc=q;return c.replace(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g,function(a){var b=h[a];return b?h.post(b.call(g,e,c)):a.replace(/\[(.*)]/,"$1")})};b.parse=function(a,c,q){var e=l[n],g=e.parser.pre(a),h=0,f,m,v=/(MMMM?|A)|(YYYY)|(SSS)|(MM|DD|HH|hh|mm|ss)|(YY|M|D|H|h|m|s|SS)|(S)|(.)/g,p={2:/^\d{1,4}/,3:/^\d{1,3}/,4:/^\d\d/,5:/^\d\d?/,6:/^\d/};a=[31,28,31,30,31,30,31,31, | ||
30,31,30,31];for(var d={Y:1970,M:1,D:1,H:0,m:0,s:0,S:0};f=v.exec(c);){var r=0;var t=1;for(m="";!m;)m=f[++r];f=m.charAt(0);var u=g.slice(h);if(2>r){var k=e.parser[m].call(e,u,c);d[f]=k.index;"M"===f&&d[f]++;t=k.length}else if(7>r)k=(u.match(p[r])||[""])[0],d[f]=("S"===f?(k+"000").slice(0,-m.length):k)|0,t=k.length;else if(" "!==f&&f!==u[0])return NaN;if(!t)return NaN;h+=t}if(h!==g.length||!k)return NaN;d.Y+=70>d.Y?2E3:100>d.Y?1900:0;d.H=d.H||e.parser.h(d.h||0,d.A||0);c=new Date(d.Y,d.M-1,d.D,d.H,d.m, | ||
b.format=function(a,c,q){var e=b.addMinutes(a,q?a.getTimezoneOffset():0),g=k[n],h=g.formatter;e.utc=q;return c.replace(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g,function(a){var b=h[a];return b?h.post(b.call(g,e,c)):a.replace(/\[(.*)]/,"$1")})};b.parse=function(a,c,q){var e=k[n],g=e.parser.pre(a),h=0,f,m,v=/(MMMM?|A)|(YYYY)|(SSS)|(MM|DD|HH|hh|mm|ss)|(YY|M|D|H|h|m|s|SS)|(S)|(.)/g,p={2:/^\d{1,4}/,3:/^\d{1,3}/,4:/^\d\d/,5:/^\d\d?/,6:/^\d/};a=[31,28,31,30,31,30,31,31, | ||
30,31,30,31];for(var d={Y:1970,M:1,D:1,H:0,m:0,s:0,S:0};f=v.exec(c);){var r=0;var t=1;for(m="";!m;)m=f[++r];f=m.charAt(0);var u=g.slice(h);if(2>r){var l=e.parser[m].call(e,u,c);d[f]=l.index;"M"===f&&d[f]++;t=l.length}else if(7>r)l=(u.match(p[r])||[""])[0],d[f]=("S"===f?(l+"000").slice(0,-m.length):l)|0,t=l.length;else if(" "!==f&&f!==u[0])return NaN;if(!t)return NaN;h+=t}if(h!==g.length||!l)return NaN;d.Y+=70>d.Y?2E3:100>d.Y?1900:0;d.H=d.H||e.parser.h(d.h||0,d.A||0);c=new Date(d.Y,d.M-1,d.D,d.H,d.m, | ||
d.s,d.S);a[1]+=b.isLeapYear(c)|0;return 1>d.M||12<d.M||1>d.D||d.D>a[d.M-1]||23<d.H||59<d.m||59<d.s?NaN:q?b.addMinutes(c,-c.getTimezoneOffset()):c};b.isValid=function(a,c){return!!b.parse(a,c)};b.addYears=function(a,c){return b.addMonths(a,12*c)};b.addMonths=function(a,c){var b=new Date(a.getTime());b.setMonth(b.getMonth()+c);return b};b.addDays=function(a,c){var b=new Date(a.getTime());b.setDate(b.getDate()+c);return b};b.addHours=function(a,c){return b.addMilliseconds(a,36E5*c)};b.addMinutes=function(a, | ||
c){return b.addMilliseconds(a,6E4*c)};b.addSeconds=function(a,c){return b.addMilliseconds(a,1E3*c)};b.addMilliseconds=function(a,b){return new Date(a.getTime()+b)};b.subtract=function(a,b){var c=a.getTime()-b.getTime();return{toMilliseconds:function(){return c},toSeconds:function(){return c/1E3|0},toMinutes:function(){return c/6E4|0},toHours:function(){return c/36E5|0},toDays:function(){return c/864E5|0}}};b.isLeapYear=function(a){a=a.getFullYear();return!(a%4)&&!!(a%100)||!(a%400)};b.isSameDay=function(a, | ||
c){return b.format(a,"YYYYMMDD")===b.format(c,"YYYYMMDD")};b.locale=function(a){a&&("en"!==a&&"function"===typeof require&&p&&require("./locale/"+a),n=a);return n};b.getLocales=function(a){return l[a||n]};b.setLocales=function(a,b){var c=function(a,b){var c=function(){},e;c.prototype=b;c=new c;for(e in a)a.hasOwnProperty(e)&&(c[e]=a[e]);return c},e=l[a]||l.en,g=c(b,e);b.formatter&&(g.formatter=c(b.formatter,e.formatter));b.parser&&(g.parser=c(b.parser,e.parser));l[a]=g};"object"===typeof module&& | ||
"object"===typeof module.exports?module.exports=b:"function"===typeof define&&define.amd?define([],function(){return b}):p.date=b})(this); | ||
c){return b.format(a,"YYYYMMDD")===b.format(c,"YYYYMMDD")};b.locale=function(a){a&&(!k[a]&&"function"===typeof require&&p&&require("./locale/"+a),n=a);return n};b.getLocales=function(a){return k[a||n]};b.setLocales=function(a,b){var c=function(a,b){var c=function(){},e;c.prototype=b;c=new c;for(e in a)a.hasOwnProperty(e)&&(c[e]=a[e]);return c},e=k[a]||k.en,g=c(b,e);b.formatter&&(g.formatter=c(b.formatter,e.formatter));b.parser&&(g.parser=c(b.parser,e.parser));k[a]=g};"object"===typeof module&&"object"=== | ||
typeof module.exports?module.exports=b:"function"===typeof define&&define.amd?define([],function(){return b}):p.date=b})(this); |
{ | ||
"name": "date-and-time", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "A Minimalist DateTime utility for Node.js and the browser", | ||
@@ -5,0 +5,0 @@ "main": "date-and-time.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85410