Comparing version 2.7.2 to 2.8.0
@@ -0,1 +1,6 @@ | ||
2.8.0 / 2020-06-08 | ||
================== | ||
* Interpret single integer input as Unix timestamp (like native Date) | ||
* Interpret 5+ digit strings as Unix timestamp | ||
2.6.0 / 2019-03-15 | ||
@@ -2,0 +7,0 @@ ================== |
17
index.js
@@ -12,2 +12,4 @@ 'use strict' | ||
const UNIX_TIME = /^\d{5,}$/ | ||
function edtf(...args) { | ||
@@ -17,6 +19,15 @@ if (!args.length) | ||
if (args.length === 1 && typeof args[0] === 'object') | ||
return new (edtf[args[0].type] || edtf.Date)(args[0]) | ||
if (args.length === 1) { | ||
switch (typeof args[0]) { | ||
case 'object': | ||
return new (edtf[args[0].type] || edtf.Date)(args[0]) | ||
case 'number': | ||
return new edtf.Date(args[0]) | ||
case 'string': | ||
if ((UNIX_TIME).test(args[0])) | ||
return new edtf.Date(Number(args[0])) | ||
} | ||
} | ||
const res = parse(...args) | ||
let res = parse(...args) | ||
return new edtf[res.type](res) | ||
@@ -23,0 +34,0 @@ } |
{ | ||
"name": "edtf", | ||
"version": "2.7.2", | ||
"version": "2.8.0", | ||
"description": "Extended Date Time Format (EDTF) / ISO 8601-2 Parser and Library", | ||
@@ -42,6 +42,6 @@ "main": "index.js", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.0.0", | ||
"eslint": "^7.2.0", | ||
"istanbul": "^0.4.3", | ||
"mocha": "^7.1.2" | ||
"mocha": "^7.2.0" | ||
} | ||
} |
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
126317
2021