From 5ccd909b2a9cecf5de85158a2393b40d580cb063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Sun, 3 May 2015 14:32:20 +0300 Subject: [PATCH] Fixed #45. Show the time range in the box --- lib/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 03c2c04..beb9a01 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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