Talk:Freedom Falls Timekeeping (Proposed)

From AiteRP Wiki
Revision as of 10:02, 5 December 2016 by Gisle (talk | contribs) (Script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Script

The following node.js script is used to calculate skip-dates. It depends on the dateformat module.

 let dateformat = require('dateformat');
 const DAY = 1000 * 60 * 60 * 24;
 
 if (process.argv.length < 5) {
   console.error("skipdates <skip> <count> <date...>");
   process.exit(1);
 }
 
 let skip = parseInt(process.argv[2]) * DAY;
 let count = parseInt(process.argv[3]);
 let date = new Date(dateformat(process.argv.slice(4).join(' ')));
 
 if(Number.isNaN(count) || Number.isNaN(skip)) {
   console.error('<skip> and <count> has to be numbers.')
   process.exit(1);
 }
 
 for(let i = 1; i <= count; ++i) {
   let skipDate = new Date((date - 0) + (skip * i));
   console.log(dateformat(skipDate, "mmmm d, yyyy (dddd)"));
 }

The command ran to generate the list on the page is. Change 32 for another number to generate more or fewer dates.

 node . 25 32 October 24, 2185

Gisle (talk) 11:02, 5 December 2016 (CET)