mirror of
https://github.com/IonicaBizau/git-stats.git
synced 2024-11-16 17:08:32 +01:00
Merge branch 'as0n-month-position'
This commit is contained in:
commit
9d9dd9710d
2 changed files with 23 additions and 6 deletions
26
lib/index.js
26
lib/index.js
|
@ -287,12 +287,13 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var year = []
|
var year = []
|
||||||
, months = []
|
, months = new Array(52) // Stores the months depending on their first week
|
||||||
, cWeek = [" ", " ", " ", " ", " ", " ", " "]
|
, cWeek = [" ", " ", " ", " ", " ", " ", " "]
|
||||||
, monthHack = "MM"
|
, monthHack = "MM"
|
||||||
, sDay = ""
|
, sDay = ""
|
||||||
, cDayObj = null
|
, cDayObj = null
|
||||||
, strYear = ""
|
, strYear = ""
|
||||||
|
, strMonths = ""
|
||||||
, w = 0
|
, w = 0
|
||||||
, d = 0
|
, d = 0
|
||||||
, dataClone = {
|
, dataClone = {
|
||||||
|
@ -305,9 +306,6 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
if (err) { return callback(err); }
|
if (err) { return callback(err); }
|
||||||
GitStats.iterateDays(dataClone, function (cDay, mDay) {
|
GitStats.iterateDays(dataClone, function (cDay, mDay) {
|
||||||
sDay = mDay.format("ddd");
|
sDay = mDay.format("ddd");
|
||||||
if (mDay.format("D") === "1") {
|
|
||||||
months.push(mDay.format("MMM"));
|
|
||||||
}
|
|
||||||
|
|
||||||
cDayObj = cal.days[cDay];
|
cDayObj = cal.days[cDay];
|
||||||
if (!cDayObj) return;
|
if (!cDayObj) return;
|
||||||
|
@ -317,6 +315,11 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
cWeek = [" ", " ", " ", " ", " ", " ", " "];
|
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];
|
cWeek[DAYS.indexOf(sDay)] = LEVELS[cDayObj.level];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -337,8 +340,19 @@ GitStats.ansiCalendar = function (data, callback) {
|
||||||
return DAYS[i] + c;
|
return DAYS[i] + c;
|
||||||
}).join("\n");
|
}).join("\n");
|
||||||
|
|
||||||
monthHack = "MMM";
|
// Months label
|
||||||
strYear = monthHack + months.join(" ") + "\n" + strYear;
|
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 +=
|
strYear +=
|
||||||
new Array(5 + 2 * Math.ceil(365 / 7)).join("-")
|
new Array(5 + 2 * Math.ceil(365 / 7)).join("-")
|
||||||
+ "\n" + "Contributions in the last year: " + cal.total
|
+ "\n" + "Contributions in the last year: " + cal.total
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
"test": "node test"
|
"test": "node test"
|
||||||
},
|
},
|
||||||
"author": "Ionică Bizău <bizauionica@gmail.com>",
|
"author": "Ionică Bizău <bizauionica@gmail.com>",
|
||||||
|
"contributors": [
|
||||||
|
"Gnab <as0n@gnab.fr>"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in a new issue