Comparing version 1.3.0 to 1.4.0
@@ -12,14 +12,8 @@ 'use strict' | ||
function tidyNumber (value) { | ||
if (value < 10) { | ||
return '0' + String(value) | ||
} | ||
if (value < 10) return '0' + String(value) | ||
return String(value) | ||
} | ||
function tidyMs (value) { | ||
if (value < 10) { | ||
return '00' + String(value) | ||
} | ||
if (value < 100) { | ||
return '0' + String(value) | ||
} | ||
if (value < 10) return '00' + String(value) | ||
if (value < 100) return '0' + String(value) | ||
return String(value) | ||
@@ -35,19 +29,16 @@ } | ||
} | ||
var tz = date.toUTCString().split(' ') | ||
return pattern | ||
.replace('d', tidyNumber(date.getUTCDate())) | ||
.replace('M', tidyNumber(date.getUTCMonth() + 1)) | ||
.replace('y', String(date.getUTCFullYear()).substring(2, 4)) | ||
.replace('Y', String(date.getUTCFullYear())) | ||
.replace('h', tidyNumber(date.getHours())) | ||
.replace('m', tidyNumber(date.getMinutes())) | ||
.replace('s', tidyNumber(date.getSeconds())) | ||
.replace('l', tidyMs(date.getMilliseconds())) | ||
.replace('d', tidyNumber(date.getUTCDate())) | ||
.replace('M', tidyNumber(date.getUTCMonth() + 1)) | ||
.replace('y', String(date.getUTCFullYear()).substring(2, 4)) | ||
.replace('Y', String(date.getUTCFullYear())) | ||
.replace('h', tidyNumber(date.getHours())) | ||
.replace('m', tidyNumber(date.getMinutes())) | ||
.replace('s', tidyNumber(date.getSeconds())) | ||
.replace('l', tidyMs(date.getMilliseconds())) | ||
.replace('z', tz[tz.length - 1]) | ||
} | ||
if (typeof module === 'object') { | ||
module.exports = easydate | ||
} | ||
if (typeof window === 'object') { | ||
window.easydate = easydate | ||
} | ||
if (typeof module === 'object') module.exports = easydate | ||
if (typeof window === 'object') window.easydate = easydate |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "get date and/or time by pattern", | ||
@@ -12,0 +12,0 @@ "keywords": [ |
@@ -30,2 +30,4 @@ 'use strict' | ||
assert.notEqual(easydate('z'), null) | ||
// invalid string (aside from an empty string) will throw | ||
@@ -32,0 +34,0 @@ try { |
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
6630
73