. NET displays the code for today's lunar calendar!

Source: Internet
Author: User

The original Published time: 2010-04-11--from my Baidu article [imported by moving tools]

Using System;
Using system.globalization;//

Namespace Project.chinadate
{

///
<summary>
Show today's Lunar class
///
</summary>


Public
Class Cndate
{
Private DateTime m_date; Today's date

Private
ReadOnly
int CNY; Lunar Calendar month and day

Private
int CNM; Lunar Calendar month and day

Private
ReadOnly
int CND; Lunar Calendar month and day

Private
ReadOnly
int ICNM; Lunar Leap Month

///
<summary>
Display Date Constructors
///
</summary>

Public Cndate ()
{
M_date = Datetime.today;
Chineselunisolarcalendar Cncalendar =
New Chineselunisolarcalendar ();
CNY = Cncalendar.getsexagenaryyear (m_date);
CNM = Cncalendar.getmonth (m_date);
CND = Cncalendar.getdayofmonth (m_date);
ICNM = Cncalendar.getleapmonth (Cncalendar.getyear (m_date));
}
///
<summary>
Returns the formatted Gregorian display
///
</summary>
///
<returns> format: May 14, 2008 </returns>

Public
String GetDate ()
{
int y = m_date.year;
int m = M_date.month;
int d = m_date.day;
Return String.Format ("{0} year {1:00} month {2:00} days", Y, M, d);
}
///
<summary>
Returns the formatted week display
///
</summary>
///
<returns> format: Sunday </returns>

Public
String Getweek ()
{
string ws =
"Week";
int w = Convert.ToInt32 (M_date.dayofweek);
WS = WS +
"Day 123456". Substring (w, 1);
return WS;
}
///
<summary>
Returns the formatted lunar calendar display
///
</summary>
///
<returns> format: E (rat) annual Run April 23 </returns>

Public
String Getcndate ()
{
String Txcns =
"";
Const
String szText1 =
"N-propyl-n-butyl-B-heptyl-nonylphenol";
Const
String szText2 =
"Hai obscure Chen Wu has not Shin";
Const
String szText3 =
"Pig mouse cow tiger dragon snake horse sheep monkey chicken Dog";
int tn = CNY%
10; Zodiac

int DN = CNY%
12; Earthly Branches
Txcns + = Sztext1.substring (tn, 1);
Txcns + = sztext2.substring (DN, 1);
Txcns + =
"("
+ sztext3.substring (DN, 1) +
") year";
Format Month Display

String[] Cnmonth ={"", "the lunar month", "February", "March", "April", "May", "June"
, "July", "August", "September", "October", "November", "December", "December"};
if (ICNM >
0)
{
for (int i = ICNM +
1; I <
13; i++) Cnmonth = Cnmonth[i-
1];
CNMONTH[ICNM] =
Leap
+ CNMONTH[ICNM];
}
Txcns + = CNMONTH[CNM];
String[] Cnday ={"", "the Junior", "Second day", "Third Day", "four", "Duanwu", "Arrest", "When初七because"
, "Holidays", "Penggushan", "decade", "11", "12", "13", "14", "XV", "16"
, "17", "18", "19", "20", "21", "22", "23", "24", "25"
, "26", "27", "28", "29", "30"};
Txcns + = cnday[cnd];
return TXCNS;
}
}

. NET displays the code for today's 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.