I have written one before, and I am very stupid. I use a bunch of IF... else and switch.
Although there is no technical contentCodeMore concise.
< Script >
// Take the Chinese zodiac. The parameter must be a four-digit year.
Function Getshengxiao (yyyy ){
// By go_rush (A Shun) from http://ashun.cnblogs.com/
VaR Arr = ['Monkey ', 'chicken', 'Dog', 'pig', 'rat ', 'ox', 'tiger ', 'rabbit', 'long ', 'snake ', 'Ma', 'sheep'];
Return /^ \ D { 4 } $ / . Test (YYYY) ? Arr [yyyy % 12 ]: Null
}
// Constellation. The parameters are month and date.
Function Getxingzuo (month, day ){
// By go_rush (A Shun) from http://ashun.cnblogs.com/
VaR D = New Date ( 1999 , Month - 1 , Day, 0 , 0 , 0 );
VaR Arr = [];
Arr. Push ([ " Capricorn " , New Date ( 1999 , 0 , 1 , 0 , 0 , 0 )])
Arr. Push ([ " Aquarius " , New Date ( 1999 , 0 , 20 , 0 , 0 , 0 )])
Arr. Push ([ " Pisces " , New Date ( 1999 , 1 , 19 , 0 , 0 , 0 )])
Arr. Push ([ " Goat's seat " , New Date ( 1999 , 2 , 21 , 0 , 0 , 0 )])
Arr. Push ([ " Taurus " , New Date ( 1999 , 3 , 21 , 0 , 0 , 0 )])
Arr. Push ([ " Gemini " , New Date ( 1999 , 4 , 21 , 0 , 0 , 0 )])
Arr. Push ([ " Cancer " , New Date ( 1999 , 5 , 22 , 0 , 0 , 0 )])
Arr. Push ([ " Leo " , New Date ( 1999 , 6 , 23 , 0 , 0 , 0 )])
Arr. Push ([ " Virgo " , New Date ( 1999 , 7 , 23 , 0 , 0 , 0 )])
Arr. Push ([ " Libra " , New Date ( 1999 , 8 , 23 , 0 , 0 , 0 )])
Arr. Push ([ " Scorpio " , New Date ( 1999 , 9 , 23 , 0 , 0 , 0 )])
Arr. Push ([ " Sagittarius " , New Date ( 1999 , 10 , 22 , 0 , 0 , 0 )])
Arr. Push ([ " Capricorn " , New Date ( 1999 , 11 , 22 , 0 , 0 , 0 )])
For ( VaR I = Arr. Length - 1 ; I > = 0 ; I -- ){
If (D > = Arr [I] [ 1 ]) Return Arr [I] [ 0 ];
}
}
/*
Capricorn (12/22-1/19), Aquarius (1/20-2/18), Pisces (2/19-3/20), Aries (3/21-4/20), Taurus (4/21-5/20 ),
GEMINI (5/21-6/21), cancer (6/22-7/22), Leo (7/23-8/22), Virgo (8/23-9/22), Libra (9/23-10/22 ),
SCORPIO (10/23-11/21), Sagittarius (11/22-12/21)
*/
</Script>