标签:style returns span sed return date i++ ram pre
/// <summary> /// 根据日期获得节气 /// </summary> /// <param name="date"></param> /// <returns></returns> public string terms(DateTime date) { 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 = date.Year; for (int i = 1; i <= 24; i++) { num = 525948.76 * (y - 1900) + sTermInfo[i - 1]; newDate = baseDateAndTime.AddMinutes(num); if (newDate.DayOfYear == date.DayOfYear) { tempStr = SolarTerm[i - 1]; break; } } return tempStr; }
标签:style returns span sed return date i++ ram pre
原文地址:https://www.cnblogs.com/6B23/p/12205811.html