Skip to content

Instantly share code, notes, and snippets.

@achengfu
Forked from solodxg/constellation.js
Created August 26, 2016 09:36
Show Gist options
  • Save achengfu/5fab09738abb4d14797535c94941abaa to your computer and use it in GitHub Desktop.
Save achengfu/5fab09738abb4d14797535c94941abaa to your computer and use it in GitHub Desktop.
js:生日转换为星座
/**
/* 生日转换为星座
/* @param mon 月份
/* @param day 日份(1-31)
/* @return string 对应日期生日的星座字符串
**/
function constellation(mon, day) {
var s = "魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
var d = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
var i = mon * 2 - (day < d[mon - 1] ? 2 : 0);
return s.substring(i, i + 2) + "座";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment