Last active
August 29, 2015 14:20
-
-
Save koohz/0e5d94d0e8534d55edc2 to your computer and use it in GitHub Desktop.
Get Season By Given Day and Month
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
/* | |
* 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