private static DateTime ChineseConstellationReferDay = new DateTime(2007, 9, 13);
private static string[] _chineseConstellationName =
{
"角木蛟","亢金龙","女土蝠","房日兔","心月狐","尾火虎","箕水豹",
"斗木獬","牛金牛","氐土貉","虚日鼠","危月燕","室火猪","壁水獝",
"奎木狼","娄金狗","胃土彘","昴日鸡","毕月乌","觜火猴","参水猿",
"井木犴","鬼金羊","柳土獐","星日马","张月鹿","翼火蛇","轸水蚓"
};
public static string ChineseConstellation(DateTime date)
{
int offset = 0;
int modStarDay = 0;
TimeSpan ts = date - ChineseConstellationReferDay;
offset = ts.Days;
modStarDay = offset % 28;
return (modStarDay >= 0 ? _chineseConstellationName[modStarDay] : _chineseConstellationName[27 + modStarDay]);
}
C#计算28星宿
最新推荐文章于 2025-05-09 23:12:58 发布