Last night there was a question on Jay's Virtual Pub Quiz asking how many days there were until Xmas. I worked something up years ago but decided to revisit it today while waiting for Visual Studio to build my solution, this is the result:
const days2Xmas = Math.ceil( ( new Date( new Date().getMonth() == 11 && new Date().getDate() > 25 ? new Date().getFullYear() + 1 : new Date().getFullYear(), 11, 25 ) .getTime() - new Date().getTime() ) / (1000 * 60 * 60 * 24) ) console.log(days2Xmas)
No comments:
Post a Comment