The Dot Net platform is very good at global support and has to be praised
Generally, converting a Gregorian calendar into a lunar calendar is a very annoying task. You need to sort out the comparison tables for the year and month.
On the. Net platform, with international support, all these things have been provided. What we need to do is to take advantage of them.
If you don't talk much about it, go directly to the Code:
/// <Summary> /// functions for converting the Gregorian calendar into the lunar calendar /// </summary> /// <remarks> author: deltaCat </remarks> // <example> URL: http://www.zu14.cn </example> /// <param name = "solarDateTime"> date of the Gregorian calendar </param> /// <returns> date of the lunar calendar </returns> static string SolarToChineseLunisolarDate (DateTime solarDateTime) {System. globalization. chineseLunisolarCalendar cal = new System. globalization. chineseLunisolarCalendar (); int year = cal. getYear (solarDateTim E); int month = cal. getMonth (solarDateTime); int day = cal. getDayOfMonth (solarDateTime); int leapMonth = cal. getLeapMonth (year); return string. format ("lunar month {0} {1} ({2}) {3} {4} month {5} {6 }", "A, B, C, E, E, G, Xin, Xi" [(year-4) % 10], "Zi ugly Yin, Mao Chen, Wu, Wu, Xi Wei, Hai" [(year-4) % 12], "Rat, ox, Tiger, Rabbit, dragon, Snake, horse, monkey, chicken, dog, and pig" [(year-4) % 12], month = leapMonth? "Week": "", "normal June 80 or 90 winter wax" [leapMonth> 0 & leapMonth <= month? Month-1: month], "day 10, day 3" [day/10], "day 1234, day 5, day 6, day 9" [day % 10]);}
The method is very simple:
String lunar calendar = SolarToChineseLunisolarDate (DateTime. Today );
[Read the full text]