Format date

This commit is contained in:
Ionică Bizău 2015-01-26 10:21:40 +02:00
parent 380ca4308a
commit 0a5060a387
2 changed files with 4 additions and 4 deletions

View file

@ -4,7 +4,7 @@ var GitStats = require("../lib");
switch (process.argv[2]) {
case "--record":
var data = process.argv[3].trim();
var data = process.argv[3];
console.log(data);
try {
data = JSON.parse(data);

View file

@ -30,10 +30,10 @@ 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 = Moment(data.date, "DDD MMM dd HH:mm:ss yyyy");
}
if (!data.date || data.date.constructor !== Date || isNaN(data.date.getTime())) {
if (!data.date || !/^Moment|Date$/.test(data.date.constructor.name)) {
return callback(new Error("The date field should be a string or a date object."));
}
@ -48,7 +48,7 @@ GitStats.record = function (data, callback) {
// Get stats
GitStats.get(function (err, stats) {
stats = stats || {};
var day = data.date.format("MMM DDD dd, YYYY")
var day = data.date.format("MMM DDD, YYYY")
, today = stats[day] = Object(stats[day])
, repo = today[data.url] = Object(today[data.url])
;