C realizes the calculation of birthdates
- 2021-01-02 21:59:02
- OfStack
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BrithdayEigth
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string[] date = {
" jia ", " YiChou ", " BingYin ", " Ding Mao ", " wu-cheng ", " JiSi ", " GengWu ", " now ", " RenShen ", " Decyl unitary ",
" A e ", " B hai ", " C son ", " The ox ", " WuYin ", " YiMao ", " GengChen ", " Simba has ", " horse ", " Decyl not ", " JiaShen ", " YiYou ", " C xu-gou ", " Ding hai ", " E child ", " His ugly ", " Heptyl Yin ", " XinMao ", " Nonyl Chen" ", " Decyl have ", " sino-japanese ", " B not ", " BingShen ", " Ding You ", " The reform movement ", " F hai ", " the year of Gengzi ", " the year of Xinchou ", " I see him ", " Decyl bases ", " let-out ", " B the third ", " C noon ", " Ding is not ", " E" ", " YiYou ", " Heptyl xu-gou ", " xinhai ", " RenZi ", " Decyl ugly ", " JiaYin ", " YiMao ", " Chen c ", " Ding has ", " E afternoon ", " Has not ", " GengShen ", " XinYou ", " Nonyl xu-gou ", " Decyl hai "
};
public int yearZi=0;
private void btnOk_Click(object sender, EventArgs e)
{
DateTime dt=Day.Value;
int year=dt.Year;
int moon = dt.Month;
int date = dt.DayOfYear;
MessageBox.Show("Test:"+(year%60-3)+":"+moon+":"+date);
// Call the method to get the birthday of the year
String yearZi = yearZ(year);
string moonZi = moonZ(moon,year);
string dayZi = dayei(year, date);
int hour = int.Parse(hourDate.Text);
string hourZi= Hours(hour, date, year);
txtBrithday.Text = yearZi+" "+moonZi+" "+dayZi+" "+hourZi;
}
private void Form1_Load(object sender, EventArgs e)
{
}
// A method for obtaining an annual birthday
public string yearZ(int y) {
int yearZie = yearNum(y);
return date[yearZie-1];
}
public string moonZ(int m,int year) {
int yearZie = yearNum(year);
if (yearZie >= 12)
{
if (yearZie % 10 == 6 || yearZie % 10 == 1)
{
return date[2+m-1];
}
else if (yearZie % 10 == 2 || yearZie % 10 == 7) {
return date[14 + m - 1];
}
else if (yearZie % 10 == 3 || yearZie % 10 == 8)
{
return date[26 + m - 1];
}
else if (yearZi % 10 == 4 || yearZi % 10 == 9)
{
return date[38 + m - 1];
}
else if (yearZie % 10 == 5 || yearZie % 10 == 0)
{
return date[50 + m - 1 > 60 ? (m - 11) : 49 + m];
}
}
else
{
if (yearZie == 6 || yearZie == 1)
{
return date[2 + m - 1];
}
else if (yearZie == 2 || yearZie == 7)
{
return date[14 + m - 1];
}
else if (yearZie == 3 || yearZie == 8)
{
return date[26 + m - 1];
}
else if (yearZi == 4 || yearZi == 9)
{
return date[38 + m - 1];
}
else if (yearZie== 5 || yearZie == 10)
{
return date[50 + m - 1>60?(m-11):49+m];
}
}
return date[1];
}
public string dayei(int year,int day) {
int yearZie = yearNum(year);
return date[(yearZie + day)%60-1];
}
public string Hours(int hour,int day,int year) {
int yearZie=yearNum(year);
string strH = "";
int datey=(yearZie+day)%60-1;
int dateZi=datey%10;
if (dateZi == 1 || dateZi == 5)
{
strH += " a ";
}
else if (dateZi == 2 || dateZi == 6)
{
strH += " c ";
}
else if (dateZi == 3 || dateZi == 7)
{
strH += " e ";
}
else if (dateZi == 4 || dateZi == 8)
{
strH += " heptyl ";
}
else if (dateZi == 5 || dateZi == 0)
{
strH += " nonyl ";
}
if (hour > 0 && hour <= 1)
{
strH+=" The child ";
}
else if (hour > 1 && hour <= 3)
{
strH += " The ugly ";
}
else if (hour > 3 && hour <= 5)
{
strH += " Yin ";
}
else if (hour > 5 && hour <= 7)
{
strH += " sockets ";
}
else if (hour > 7 && hour <= 9)
{
strH += " Chen" ";
}
else if (hour > 9 && hour <= 11)
{
strH += " The third ";
}
else if (hour > 11 && hour <= 13)
{
strH += " noon ";
}
else if (hour > 13 && hour <= 15)
{
strH += " not ";
}
else if (hour > 15 && hour <= 17)
{
strH += " " ";
}
else if (hour > 17 && hour <= 19)
{
strH += " The child ";
}
else if (hour > 19 && hour <= 21)
{
strH += " unitary ";
}
else if (hour > 21 && hour <= 23)
{
strH += " e ";
}
else if (hour > 0 && hour <= 1)
{
strH += " hai ";
}
return strH;
}
public int yearNum(int year) {
int yearZie = year % 60 - 3;
if (yearZie <= 0)
{
yearZie += 60;
}
return yearZie;
}
}
}
That's the end of this article. I hope you enjoyed it.