Skip to content

Instantly share code, notes, and snippets.

@edwardloveall
Created November 24, 2011 08:15
Show Gist options
  • Save edwardloveall/1390880 to your computer and use it in GitHub Desktop.
Save edwardloveall/1390880 to your computer and use it in GitHub Desktop.
Return Current Season According to Equinoxes/Solstices
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