Merge branch 'as0n-month-position'

This commit is contained in:
Ionică Bizău 2015-02-18 11:29:44 +02:00
commit 9d9dd9710d
2 changed files with 23 additions and 6 deletions

View file

@ -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,19 @@ 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 < months.length; i++) {
// The length of strMonths should always be 2*(i+1) (at the i-th column)
if (!months[i]) {
strMonths += new Array(2*(i+1)-strMonths.length+1).join(" ");
} else {
strMonths += months[i];
}
}
strYear = monthHack + strMonths + "\n" + strYear;
strYear +=
new Array(5 + 2 * Math.ceil(365 / 7)).join("-")
+ "\n" + "Contributions in the last year: " + cal.total

View file

@ -10,6 +10,9 @@
"test": "node test"
},
"author": "Ionică Bizău <bizauionica@gmail.com>",
"contributors": [
"Gnab <as0n@gnab.fr>"
],
"license": "MIT",
"devDependencies": {},
"repository": {