Skip to content

Instantly share code, notes, and snippets.

@laurent22
Created November 1, 2019 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laurent22/bc17315c067ce52d8513e68e9c472ee2 to your computer and use it in GitHub Desktop.
Save laurent22/bc17315c067ce52d8513e68e9c472ee2 to your computer and use it in GitHub Desktop.
const daysPerMonth = [
31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31,
];
function twoDigits(d) {
if (d < 10) return '0' + d;
return d.toString();
}
const daysPerLine = 10;
const lines = [];
for (let month = 1; month <= 12; month++) {
const days = daysPerMonth[month - 1];
let line = [];
for (let day = 1; day <= days; day++) {
if (line.length >= daysPerLine && day !== 31) {
lines.push(line);
line = [];
}
line.push(twoDigits(day) + ' ' + twoDigits(month));
}
if (line.length) lines.push(line);
}
let lineNum = 80;
for (const line of lines) {
console.info(lineNum + ' DATA ' + line.join(','));
lineNum += 10;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment