Skip to content

Instantly share code, notes, and snippets.

@marcofranssen
Created December 20, 2013 15:23
Show Gist options
  • Save marcofranssen/8056278 to your computer and use it in GitHub Desktop.
Save marcofranssen/8056278 to your computer and use it in GitHub Desktop.
(function () {
'use strict';
var currentDate = new Date(),
christmas = Date.parse('Dec 25, ' + currentDate.getFullYear()),
newYear = Date.parse('Jan 1, ' + currentDate.getFullYear() + 1),
daysToChristmas = Math.round((christmas-today) / (1000 * 60 * 60 * 24)),
daysToNewYear = Math.round((newYear-today) / (1000 * 60 * 60 * 24));
if (daysToChristmas === 0) {
alert('Merry Christmas!');
} else if (daysToNewYear === 0) {
alert('Happy new year!');
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment