parse-messy-time
Advanced tools
Comparing version 1.2.1 to 1.2.2
11
index.js
@@ -101,2 +101,8 @@ var months = [ | ||
} | ||
else if (/^\d{4}[\W_]\d{1,2}[\W_]\d{1,2}/.test(t)) { | ||
var yms = t.split(/[\W_]/); | ||
res.year = Number(yms[0]); | ||
res.month = Number(yms[1]) - 1; | ||
res.date = Number(yms[2]); | ||
} | ||
else if (m = /^(\d+)/.exec(t)) { | ||
@@ -182,4 +188,2 @@ var x = Number(m[1]); | ||
out.setSeconds(res.seconds === undefined ? 0 : res.seconds); | ||
if (res.date !== undefined) out.setDate(res.date); | ||
if (typeof res.month === 'number') { | ||
@@ -189,3 +193,4 @@ out.setMonth(res.month); | ||
else if (res.month) out.setMonth(months.indexOf(res.month)); | ||
if (res.date !== undefined) out.setDate(res.date); | ||
if (res.year) out.setYear(res.year); | ||
@@ -192,0 +197,0 @@ return out; |
{ | ||
"name": "parse-messy-time", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "parse messy human date and time strings", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -185,3 +185,18 @@ var parse = require('../'); | ||
); | ||
t.equal( | ||
strftime('%F %T', parse('2015-10-31', optsd)), | ||
'2015-10-31 00:00:00', | ||
'YYYY-MM-DD' | ||
); | ||
t.equal( | ||
strftime('%F %T', parse('2015-10-31 20:30', optsd)), | ||
'2015-10-31 20:30:00', | ||
'YYYY-MM-DD HH:MM' | ||
); | ||
t.equal( | ||
strftime('%F %T', parse('2015-10-31 8:30pm', optsd)), | ||
'2015-10-31 20:30:00', | ||
'YYYY-MM-DD informal' | ||
); | ||
t.end(); | ||
}); |
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
20293
507