1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 08:20:11 +00:00

Generate safe date times; don't hard-code.

This commit is contained in:
devlinjd 2015-12-08 22:21:42 -05:00
parent 1a757e8a87
commit 87c03b437c

View File

@ -287,35 +287,39 @@ Definition of the FRESHResume class.
function _parseDates() { function _parseDates() {
var _fmt = require('./fluent-date').fmt; var _fmt = require('./fluent-date').fmt;
var that = this;
this.employment.history && this.employment.history.forEach( function(job) { // TODO: refactor recursion
job.safe = { function replaceDatesInObject( obj ) {
start: _fmt( job.start ),
end: _fmt( job.end || 'current' ) if( !obj ) return;
}; if( Object.prototype.toString.call( obj ) === '[object Array]' ) {
obj.forEach(function(elem){
replaceDatesInObject( elem );
}); });
this.education.history && this.education.history.forEach( function(edu) { }
edu.safe = { else if (typeof obj === 'object') {
start: _fmt( edu.start ), if( obj._isAMomentObject || obj.safe )
end: _fmt( edu.end || 'current' ) return;
}; Object.keys( obj ).forEach(function(key) {
replaceDatesInObject( obj[key] );
}); });
this.service.history && this.service.history.forEach( function(vol) { ['start','end','date'].forEach( function(val) {
vol.safe = { if( obj[val] && (!obj.safe || !obj.safe[val] )) {
start: _fmt( vol.start ), obj.safe = obj.safe || { };
end: _fmt( vol.end || 'current' ) obj.safe[ val ] = _fmt( obj[val] );
}; if( obj[val] && (val === 'start') && !obj.end ) {
obj.safe.end = _fmt('current');
}
}
}); });
this.recognition && this.recognition.forEach( function(rec) { }
rec.safe = { }
date: _fmt( rec.date )
}; Object.keys( this ).forEach(function(member){
}); replaceDatesInObject( that[ member ] );
this.writing && this.writing.forEach( function(pub) {
pub.safe = {
date: _fmt( pub.date )
};
}); });
} }
/** /**