Last active
August 29, 2015 13:56
-
-
Save yuristrelets/8812027 to your computer and use it in GitHub Desktop.
get zodiac sign
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 getZodiacSign(date) { | |
if(!(date instanceof Date)) date = new Date(); | |
var dateStr = +[ | |
date.getMonth() + 1, | |
('0' + date.getDate()).slice(-2) | |
].join('') | |
,signs = [ | |
[120, 'Capricorn'], | |
[219, 'Aquarius'], | |
[320, 'Pisces'], | |
[420, 'Aries'], | |
[521, 'Taurus'], | |
[621, 'Gemini'], | |
[722, 'Cancer'], | |
[822, 'Leo'], | |
[923, 'Virgo'], | |
[1023,'Libra'], | |
[1122, 'Scorpio'], | |
[1221, 'Sagittarius'], | |
[1231, 'Capricorn'] | |
]; | |
for(var index in signs) { | |
var item = signs[index]; | |
if(dateStr <= item[0]) return item[1]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment