1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-21 16:00:11 +00:00

Support additional date formats.

Support "Now" in addition to "Present" along with year-only dates of the
form "YYYY".
This commit is contained in:
devlinjd 2015-09-21 11:34:42 -04:00
parent f03d2a05e7
commit 7bf25469de

View File

@ -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())