Fixed #45. Show the time range in the box

This commit is contained in:
Ionică Bizău 2015-05-03 14:32:20 +03:00
parent 02589714c9
commit 5ccd909b2a

View file

@ -3,6 +3,7 @@ var Ul = require("ul")
, Fs = require("fs")
, Moment = require("moment")
, CliBox = require("cli-box")
, Couleurs = require("couleurs")()
;
// Constants
@ -296,12 +297,21 @@ GitStats.ansiCalendar = function (data, callback) {
, strMonths = ""
, w = 0
, d = 0
, when = "the last year"
, dataClone = {
start: data.start ? Moment(data.start.format(DATE_FORMAT), DATE_FORMAT) : null
, end: data.end ? Moment(data.end.format(DATE_FORMAT), DATE_FORMAT) : null
}
;
dataClone.s = data.start.format(DATE_FORMAT);
dataClone.e = data.end.format(DATE_FORMAT);
if (Moment().subtract(1, "years").format(DATE_FORMAT) !== dataClone.s
|| Moment().format(DATE_FORMAT) !== dataClone.e) {
when = [Couleurs.bold(dataClone.s), Couleurs.bold(dataClone.e)].join(" ");
}
GitStats.calendar(data, function (err, cal) {
if (err) { return callback(err); }
GitStats.iterateDays(dataClone, function (cDay, mDay) {
@ -355,7 +365,7 @@ GitStats.ansiCalendar = function (data, callback) {
strYear = monthHack + strMonths + "\n" + strYear;
strYear +=
new Array(5 + 2 * Math.ceil(365 / 7)).join("-")
+ "\n" + "Contributions in the last year: " + cal.total
+ "\n" + "Commits in " + when + ": " + cal.total
+ " | " + "Longest Streak: " + cal.lStreak + " days"
+ " | " + "Current Streak: " + cal.cStreak + " days"
+ " | " + "Max a day: " + cal.max