From a41624ea7a7befc4a7d2a166269bcb9e732f5aa9 Mon Sep 17 00:00:00 2001 From: as0n Date: Tue, 17 Feb 2015 20:11:21 +0100 Subject: [PATCH 1/3] Fixed month labels positions. Month labels always start on the column (week) of their first day and aren't just randomly spaced. --- lib/index.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 4f7df67..d98cecf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -287,12 +287,13 @@ GitStats.ansiCalendar = function (data, callback) { } var year = [] - , months = [] + , months = new Array(52) // Stores the months depending on their first week , cWeek = [" ", " ", " ", " ", " ", " ", " "] , monthHack = "MM" , sDay = "" , cDayObj = null , strYear = "" + , strMonths = "" , w = 0 , d = 0 , dataClone = { @@ -305,9 +306,6 @@ GitStats.ansiCalendar = function (data, callback) { if (err) { return callback(err); } GitStats.iterateDays(dataClone, function (cDay, mDay) { sDay = mDay.format("ddd"); - if (mDay.format("D") === "1") { - months.push(mDay.format("MMM")); - } cDayObj = cal.days[cDay]; if (!cDayObj) return; @@ -317,6 +315,11 @@ GitStats.ansiCalendar = function (data, callback) { cWeek = [" ", " ", " ", " ", " ", " ", " "]; } + // Store the new month this week + if (mDay.format("D") === "1") { + months[year.length] = mDay.format("MMM"); + } + cWeek[DAYS.indexOf(sDay)] = LEVELS[cDayObj.level]; }); @@ -337,8 +340,14 @@ GitStats.ansiCalendar = function (data, callback) { return DAYS[i] + c; }).join("\n"); - monthHack = "MMM"; - strYear = monthHack + months.join(" ") + "\n" + strYear; + // Months label + monthHack = "MMMM"; //Left padding + for (var i=0; i Date: Tue, 17 Feb 2015 20:14:59 +0100 Subject: [PATCH 2/3] Updated contributors. --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 2656513..31f010a 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "test": "node test" }, "author": "Ionică Bizău ", + "contributors": [ + "Gnab " + ], "license": "MIT", "devDependencies": {}, "repository": { From 087a393454f2057001391597ca143afb1cc09b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Wed, 18 Feb 2015 11:29:01 +0200 Subject: [PATCH 3/3] Code style --- lib/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index d98cecf..cd25d0d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -342,11 +342,16 @@ GitStats.ansiCalendar = function (data, callback) { // Months label monthHack = "MMMM"; //Left padding - for (var i=0; i