-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (26 loc) · 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
var Kollavarsham = require('kollavarsham'),
kollavarsham = new Kollavarsham(),
sprintf = require('sprintf-js').sprintf;
var separator = '-------------------------------------------------------------------------';
var getOutputForADay = function (kollavarshamDate) {
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var result = sprintf('| %4s %-9s %2s %-9s | %4s %5s %2s | %-13s ',
kollavarshamDate.gregorianDate.getFullYear(), monthNames[kollavarshamDate.gregorianDate.getMonth()],
kollavarshamDate.gregorianDate.getDate(), kollavarshamDate.weekdayName, kollavarshamDate.year,
kollavarshamDate.mlMasaName, kollavarshamDate.date, kollavarshamDate.mlNaksatraName);
return result + '\n' + separator;
};
var batchGenerator = function (year) {
var gregorianDate = new Date(year, 0, 1);
var kollavarshamDate, output = separator + '\n';
while(gregorianDate.getFullYear() === year) {
kollavarshamDate = kollavarsham.fromGregorianDate(gregorianDate);
output += getOutputForADay(kollavarshamDate) + '\n';
gregorianDate.setUTCDate(gregorianDate.getUTCDate() + 1);
}
return output;
};
module.exports = batchGenerator;