1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-03 04:47:07 +01:00

Improve date handling.

This commit is contained in:
hacksalot
2016-01-30 20:06:04 -05:00
parent 8e806dc04f
commit 27c7a0264a
7 changed files with 90 additions and 50 deletions

View File

@ -29,7 +29,7 @@ Definition of the AbstractResume class.
AbstractResume.prototype.duration = function(collKey, startKey, endKey, unit) {
var firstDate, hist, lastDate, new_e;
unit = unit || 'years';
hist = hist || __.get(this, collKey);
hist = __.get(this, collKey);
if (!hist || !hist.length) {
return 0;
}

View File

@ -60,7 +60,7 @@ The HackMyResume date representation.
module.exports = FluentDate;
FluentDate.fmt = function(dt, throws) {
var defTime, month, mt, parts, ref, temp;
var month, mt, parts, ref, temp;
throws = (throws === void 0 || throws === null) || throws;
if (typeof dt === 'string' || dt instanceof String) {
dt = dt.toLowerCase().trim();
@ -78,33 +78,7 @@ The HackMyResume date representation.
} else if (/^\s*\d{4}\s*$/.test(dt)) {
return moment(dt, 'YYYY');
} else if (/^\s*$/.test(dt)) {
defTime = {
isNull: true,
isBefore: function(other) {
if (other && !other.isNull) {
return true;
} else {
return false;
}
},
isAfter: function(other) {
if (other && !other.isNull) {
return false;
} else {
return false;
}
},
unix: function() {
return 0;
},
format: function() {
return '';
},
diff: function() {
return 0;
}
};
return defTime;
return moment();
} else {
mt = moment(dt);
if (mt.isValid()) {