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.1 to 0.2.2

16

date-and-time.js

@@ -64,2 +64,5 @@ /**

},
isCommonJS = function () {
return typeof module === 'object' && typeof module.exports === 'object';
},
forEach = function (array, fn) {

@@ -116,11 +119,10 @@ for (var i = 0, len = array.length; i < len; i++) {

date.format = function (dateObj, formatString, utc) {
var tokens = formatString.match(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g) || [],
d = new Date(dateObj.getTime() + (utc ? dateObj.getTimezoneOffset() * 60000 : 0)),
var d = new Date(dateObj.getTime() + (utc ? dateObj.getTimezoneOffset() * 60000 : 0)),
locale = locales[lang], formats = locale.formats;
d.utc = utc;
forEach(tokens, function (token, i) {
tokens[i] = (formats[token] || function () {}).call(locale, d) || token.replace(/\[(.*)]/, '$1');
return formatString.replace(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g, function (token) {
var format = formats[token];
return format ? formats.post(format.call(locale, d)) : token.replace(/\[(.*)]/, '$1');
});
return formats.post(tokens.join(''));
};

@@ -279,3 +281,3 @@

if (code) {
if (typeof module === 'object' && typeof module.exports === 'object') {
if (code !== 'en' && isCommonJS()) {
require('./locale/' + code);

@@ -328,3 +330,3 @@ }

if (typeof module === 'object' && typeof module.exports === 'object') {
if (isCommonJS()) {
module.exports = date;

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

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

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}}}},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,l=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(l,function(c){d=c.charAt(0);e=c.length;f=a.slice(b);/^(YYYY|YY|MM|DD|HH|hh|mm|ss|SS?S?)$/.test(c)?(k[d]=f.slice(0,
e)|0,"YY"===c&&(k.Y+=70>k.Y?2E3:1900)):/^(M|D|H|h|m|s)$/.test(c)?(f=(f.match(/^\d\d?/)||[""])[0],e=f.length,k[d]=f|0):/^(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=c.match(/(\[[^\[\]]*]|\[.*\][^\[]*\]|YYYY|YY|MMM?M?|DD|HH|hh|mm|ss|SSS?|ddd?d?|.)/g)||[],e=new Date(a.getTime()+(b?6E4*a.getTimezoneOffset():0)),f=g[h],l=f.formats;e.utc=b;m(d,function(a,b){d[b]=(l[a]||function(){}).call(f,e)||a.replace(/\[(.*)]/,
"$1")});return l.post(d.join(""))};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()};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)};d.subtract=function(a,c){var b=a.getTime()-c.getTime();
return{toMilliseconds:function(){return b},toSeconds:function(){return b/1E3|0},toMinutes:function(){return b/6E4|0},toHours:function(){return b/36E5|0},toDays:function(){return b/864E5|0}}};d.isLeapYear=function(a){a=a.getFullYear();return!(a%4)&&!!(a%100)||!(a%400)};d.locale=function(a){a&&("object"===typeof module&&"object"===typeof module.exports&&require("./locale/"+a),h=a);return h};d.getLocales=function(a){return g[a||h]};d.setLocales=function(a,c){var b=function(a,b){var c=function(){},d;
c.prototype=b;c=new c;for(d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);return c},d=g[a]||g.en,e=b(c,d);c.formats&&(e.formats=b(c.formats,d.formats));c.parsers&&(e.parsers=b(c.parsers,d.parsers));g[a]=e};"object"===typeof module&&"object"===typeof module.exports?module.exports=d:"function"===typeof define&&define.amd?define([],function(){return d}):p.date=d})(this);
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);/^(YYYY|YY|MM|DD|HH|hh|mm|ss|SS?S?)$/.test(c)?(k[d]=f.slice(0,e)|0,"YY"===c&&(k.Y+=70>k.Y?2E3:1900)):/^(M|D|H|h|m|s)$/.test(c)?(f=(f.match(/^\d\d?/)||[""])[0],e=f.length,k[d]=f|0):/^(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()};
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)};
d.subtract=function(a,c){var b=a.getTime()-c.getTime();return{toMilliseconds:function(){return b},toSeconds:function(){return b/1E3|0},toMinutes:function(){return b/6E4|0},toHours:function(){return b/36E5|0},toDays:function(){return b/864E5|0}}};d.isLeapYear=function(a){a=a.getFullYear();return!(a%4)&&!!(a%100)||!(a%400)};d.locale=function(a){a&&("en"!==a&&l()&&require("./locale/"+a),h=a);return h};d.getLocales=function(a){return g[a||h]};d.setLocales=function(a,c){var b=function(a,b){var c=function(){},
d;c.prototype=b;c=new c;for(d in a)a.hasOwnProperty(d)&&(c[d]=a[d]);return c},d=g[a]||g.en,e=b(c,d);c.formats&&(e.formats=b(c.formats,d.formats));c.parsers&&(e.parsers=b(c.parsers,d.parsers));g[a]=e};l()?module.exports=d:"function"===typeof define&&define.amd?define([],function(){return d}):p.date=d})(this);
{
"name": "date-and-time",
"version": "0.2.1",
"description": "Minimalist DateTime utility for Node.js and the browser",
"version": "0.2.2",
"description": "A Minimalist DateTime utility for Node.js and the browser",
"main": "date-and-time.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -1,3 +0,3 @@

# date-and-time [![Circle CI](https://circleci.com/gh/knowledgecode/date-and-time.svg?style=shield)](https://circleci.com/gh/knowledgecode/date-and-time)
This is a Minimalist DateTime utility for Node.js and the browser.
# date-and-time
[![Circle CI](https://circleci.com/gh/knowledgecode/date-and-time.svg?style=shield)](https://circleci.com/gh/knowledgecode/date-and-time)

@@ -8,3 +8,3 @@ ## WHY

## Features
- Minimalist. only 1.8k gz
- Minimalist. only has 1.8k gz
- multi language support

@@ -11,0 +11,0 @@ - not extending built-in date object

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