Skip to content

Instantly share code, notes, and snippets.

@yuristrelets
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yuristrelets/8812027 to your computer and use it in GitHub Desktop.
Save yuristrelets/8812027 to your computer and use it in GitHub Desktop.
get zodiac sign
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