You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
433 B
JavaScript

#!/usr/bin/node
if (!process.argv[2]) {
console.error("Missing argument: yyyy-mm-dd");
process.exit(1);
}
const moment = require("moment");
const birthday = moment(process.argv[2]);
let now = moment();
for (let m = moment(birthday); m.isSameOrBefore(now); m.add(1, 'y')) {
const diff = m.diff(birthday, 'years');
console.log(m.format("ddd") + ", " + m.year() + ", " + diff + " " + (diff === 1 ? "year" : "years") + " old");
}