Skip to content

Instantly share code, notes, and snippets.

@koohz
Last active August 29, 2015 14:20
Show Gist options
  • Save koohz/0e5d94d0e8534d55edc2 to your computer and use it in GitHub Desktop.
Save koohz/0e5d94d0e8534d55edc2 to your computer and use it in GitHub Desktop.
Get Season By Given Day and Month
/*
* 0 = winter
* 1 = spring
* 2 = summer
* 3 = autumn
*/
function get_season(day, month)
{
return parseInt(((month - (+(day < 21))) / 3) % 4);
}
var seasons = ["Winter", "Spring", "Summer", "Autumn"];
alert(seasons[get_season(20,3)]);
alert(seasons[get_season(21,3)]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment