mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-12-22 13:22:11 +01:00
Format date
This commit is contained in:
parent
380ca4308a
commit
0a5060a387
2 changed files with 4 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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])
|
||||
;
|
||||
|
|
Loading…
Reference in a new issue