From 7bf25469de41979b7bdc32fc91f7475b96bc5c1c Mon Sep 17 00:00:00 2001 From: devlinjd Date: Mon, 21 Sep 2015 11:34:42 -0400 Subject: [PATCH] Support additional date formats. Support "Now" in addition to "Present" along with year-only dates of the form "YYYY". --- src/sheet.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sheet.js b/src/sheet.js index 68425f4..b48498d 100644 --- a/src/sheet.js +++ b/src/sheet.js @@ -103,13 +103,16 @@ Abstract character/resume sheet representation. */ function _fmt( dt ) { dt = dt.toLowerCase().trim(); - if( dt === 'present' ) { + if( /\s*(present|now)\s*/i.test(dt) ) { // "Present", "Now" return moment(); } - else if( /^\D+/.test(dt) ) { + else if( /^\D+/.test(dt) ) { // "Mar 2015" var parts = dt.split(' '); return moment( parts[1] + '-' + (months[ parts[0] ] || abbr[ parts[0] ] || ( parts[0] === 'sept' && '09' )) + '-' + '01', 'YYYY-MM-DD' ); } + else if( /^\d+$/.test(dt) ) { // "2015" + return moment( dt, 'YYYY' ); + } else { var mt = moment( dt ); if(mt.isValid())