From a1b44b230af978505222eaee1edbf52aa000e293 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 17 Apr 2011 10:03:45 +0200 Subject: Make logger.timeSheetRecordsPrinter testeable and add unit test. --- lib/logger.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/logger.js') diff --git a/lib/logger.js b/lib/logger.js index d4c5dc9..0b18c1b 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -74,22 +74,21 @@ function getBugzillaAbbr(url) { } exports.generateTimeSheet = function generateTimeSheet() { - var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs); + var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs, new Date()); libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML); }; -function timeSheetRecordsPrinter(records) { +exports.timeSheetRecordsPrinter = function timeSheetRecordsPrinter(records, date) { var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g"); // sort the records into temporary array var tmpArr = []; - var today = new Date(); - var todayStr = today.getFullYear() + "-" + - xrpc.leadingZero(today.getMonth()+1) + "-" + - xrpc.leadingZero(today.getDate()); + var dateStr = date.getFullYear() + "-" + + xrpc.leadingZero(date.getMonth()+1) + "-" + + xrpc.leadingZero(date.getDate()); var outStr = '' + "\n"+ "\n"+ - "TimeSheet-"+ todayStr + "\n\n\n" + + "TimeSheet-"+ dateStr + "\n\n\n" + "

TimeSheet

\n"; for (var i in records) { -- cgit