C # Gregorian calendar to lunar calendar

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.