积极答复者
请帮忙看看这个计算24节气的程序吧。。。

问题
-
代码:
public static string ChineseTwentyFourDay(DateTime date1) { string[] SolarTerm = new string[] { "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至" }; int[] sTermInfo = new int[] { 0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758 }; DateTime baseDateAndTime = new DateTime(1900, 1, 6, 2, 5, 0); //#1/6/1900 2:05:00 AM# DateTime newDate; double num; int y; string tempStr = ""; y = date1.Year; for (int i = 1; i <= 24; i++) { num = 525948.76 * (y - 1900) + sTermInfo[i - 1]; newDate = baseDateAndTime.AddMinutes(num);//按分钟计算 if (newDate.DayOfYear < date1.DayOfYear) { //tempStr = SolarTerm[i - 1]; tempStr = string.Format("{0}[{1}]", SolarTerm[i - 1], newDate.ToString("yyyy-MM-dd")); Console.WriteLine(tempStr); //break; } } return tempStr; }
我这里用Console输出所有节气(参数“date1”之前的所有节气),我对比了一下,发现有一个是错误的,就是“大暑”,baidu上查到是7-22,但是这个程序计算是7-23
感觉这个程序不太靠谱,请大家帮忙看看那里错了?
da jia hao!
答案
-
Hi,
我测试你的代码和百度的显示的的确是差了一天,我看来你的算法,个人觉得你应该尝试下面的算法,这样可能会准确一点,
因为手算大暑 是对应上的。好像中国的每个节气算法都有细微的差别,我们要分别计算。
https://zhidao.baidu.com/question/469233390.html
Best Regards,
Hart
注意:此回复包含对第三方万维网站点的引用。 Microsoft提供此信息为您提供方便。 Microsoft不控制这些网站,并且没有测试在这些网站上发现的任何软件或信息; 因此,Microsoft不能对任何软件或信息的质量,安全性或适用性做任何声明。 使用互联网上发现的任何软件都存在固有的危险,Microsoft警告您,在从互联网检索任何软件之前,请确保您完全理解风险。
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- 已标记为答案 liubin 2017年10月10日 9:15
全部回复
-
Hi,
感谢你在MSDN论坛发帖。
你能提供一份可以重现问题的代码在 one drive上面吗?这样方便我们测试一下。
其他节气都对吗? 只有大暑错了吗?
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
-
Hi,
我测试你的代码和百度的显示的的确是差了一天,我看来你的算法,个人觉得你应该尝试下面的算法,这样可能会准确一点,
因为手算大暑 是对应上的。好像中国的每个节气算法都有细微的差别,我们要分别计算。
https://zhidao.baidu.com/question/469233390.html
Best Regards,
Hart
注意:此回复包含对第三方万维网站点的引用。 Microsoft提供此信息为您提供方便。 Microsoft不控制这些网站,并且没有测试在这些网站上发现的任何软件或信息; 因此,Microsoft不能对任何软件或信息的质量,安全性或适用性做任何声明。 使用互联网上发现的任何软件都存在固有的危险,Microsoft警告您,在从互联网检索任何软件之前,请确保您完全理解风险。
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- 已标记为答案 liubin 2017年10月10日 9:15