Created
November 24, 2011 08:15
-
-
Save edwardloveall/1390880 to your computer and use it in GitHub Desktop.
Return Current Season According to Equinoxes/Solstices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSeason (dateString) { // format "mm/dd/yy" | |
var d = typeof(dateString) == "undefined" ? new Date() : new Date(dateString), // use today if nothing is passed in | |
month = d.getMonth()+1, | |
day = d.getDate(), | |
seasonCode = month+(day/100); // mm.dd | |
if (seasonCode < 3.21) { return "Winter"} | |
else if (seasonCode < 6.21) { return "Spring"} | |
else if (seasonCode < 9.22) { return "Summer"} | |
else if (seasonCode < 12.21) { return "Fall"} | |
else if (seasonCode >= 12.21) { return "Winter"} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment