Parse date

This commit is contained in:
Ionică Bizău 2015-01-26 10:47:13 +02:00
parent b8e211716e
commit 10d571fa63
1 changed files with 2 additions and 2 deletions

View File

@ -17,7 +17,7 @@ var GitStats = module.exports = {};
* @function
* @param {Object} data The commit data containing:
*
* - `date` (String|Date): The date object or a string in this format: `DDD MMM dd HH:mm:ss YYYY`
* - `date` (String|Date): The date object or a string in a format that can be parsed.
* - `url` (String): The repository remote url.
* - `hash` (String): The commit hash.
*
@ -30,7 +30,7 @@ GitStats.record = function (data, callback) {
callback = callback || function (err) { if (err) throw err; };
data = Object(data);
if (typeof data.date === "string") {
data.date = Moment(data.date, "DDD MMM dd HH:mm:ss yyyy");
data.date = new Moment(new Date(data.date));
}
if (!data.date || !/^Moment|Date$/.test(data.date.constructor.name)) {