今天是端午节,明天是生日,后天还是生日(农历),哈哈,连续三天过节阿
突发奇想,公历和农历交叉,碰到连续两天的机会有多少次呢?
作了一段小程序算了算,也不知道是不是巧合,65岁以前,正好19年一次,今年碰到也算是难得,记在这里留个纪念:〉
P.S. 感谢七月(梦虫夏天) 整理的农历转换类的代码
P.S.P.S 转换函数代码附下:
LunarDate ld = new LunarDate(new DateTime(year, month, day));
for (int i = year; i <= 2050; i++)
{
LunarDate ld2 = new LunarDate(new DateTime(i, month, day));
if (ld2.Month == ld.Month )
{
if (ld2.Day >= ld.Day – 1 && ld2.Day <= ld.Day + 1)
{
ListViewItem lvi = listView1.Items.Add(ld2.Year.ToString());
lvi.SubItems.Add((ld2.Day – ld.Day).ToString());
}
}
}
for (int i = year; i <= 2050; i++)
{
LunarDate ld2 = new LunarDate(new DateTime(i, month, day));
if (ld2.Month == ld.Month )
{
if (ld2.Day >= ld.Day – 1 && ld2.Day <= ld.Day + 1)
{
ListViewItem lvi = listView1.Items.Add(ld2.Year.ToString());
lvi.SubItems.Add((ld2.Day – ld.Day).ToString());
}
}
}