Your sister's SB. Simple method of C # (ASP. NET) Gregorian calendar to lunar calendar
Dot Net Platform, the support of globalization has done very well, have to praise a
Usually, the Gregorian calendar into the lunar calendar, is a very annoying thing, need to organize leap years, leap month and other tables.
On the. NET platform, with the internationalization of support, these things have been provided, we need to do, just use it.
Words not much to say, directly on the code:
<summary>///Functions of Gregorian calendar to lunar calendar</summary>///<remarks>Deltacat</remarks>///<example>Website: http://www.zu14.cn</example>///<param name= "Solardatetime" >Gregorian Date</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 (Solardatetime); int month = cal. GetMonth (Solardatetime); int day = cal. GetDayOfMonth (Solardatetime); int leapmonth = cal. Getleapmonth (year); return string. Format ("lunar Calendar {0}{1} ({2}) year {3}{4} month {5}{6}", "methyl-propyl-Xing" [(year-4)%], "obscure" [[Shin]%], " Mouse cow tiger rabbit dragon snake horse sheep monkey chicken Dog Pig "[(year-4)%], month = = Leapmonth? "leap": "" , "no positive 234,567,890 winter wax" [leapmonth > 0 && leapmonth <= month? Month-1: Month], "beginning 33" [DAY/10], "Day 123456789" [days]);}
The method used is very simple:
string Lunar calendar = solartochineselunisolardate (DateTime. Today);
C # Gregorian calendar to lunar calendar