c 版公曆轉農曆

2021-06-16 06:54:39 字數 3174 閱讀 7931

using system;

namespace ljtools

; private static int year20 = new int ;

private static int year19 = new int ;

private static int year2000 = new int ;

private static string nstr1 = new string ;

private static string gan = new string ;

private static string zhi = new string ;

private static string animals = new string ;

private static string solarterm = new string ;

private static int sterminfo =;

private static string sftv = new string ;

private static string lftv = new string ;

/// /// 傳回農曆 y年的總天數

///

///

///

private static int lyeardays(int y)

return (sum + leapdays(y));

}/// /// 傳回農曆 y年閏月的天數

///

///

///

private static int leapdays(int y)

else

return 0;

}/// /// 傳回農曆 y年閏哪個月 1-12 , 沒閏傳回 0

///

///

///

private static int leapmonth(int y)

/// /// 傳回農曆 y年m月的總天數

///

///

///

///

private static int monthdays(int y, int m)

/// /// 傳回農曆 y年的生肖

///

///

///

private static string animalsyear(int y)

/// /// 傳入 月日的offset 傳回干支,0=甲子

///

///

///

private static string cyclicalm(int num)

/// /// 傳入 offset 傳回干支, 0=甲子

///

///

///

private static string cyclical(int y)

/// /// 傳出農曆.year0 .month1 .day2 .yearcyl3 .moncyl4 .daycyl5 .isleap6

///

///

///

///

private long lunar(int y, int m)

if (offset < 0)

nongdate[0] = i;

nongdate[3] = i - 1864;

leap = leapmonth(i); // 閏哪個月

nongdate[6] = 0;

for (i = 1; i < 13 && offset > 0; i++)

else

// 解除閏月

if (nongdate[6] == 1 && i == (leap + 1))

nongdate[6] = 0;

offset -= temp;

if (nongdate[6] == 0)

nongdate[4]++;

}if (offset == 0 && leap > 0 && i == leap + 1)

else

}if (offset < 0)

nongdate[1] = i;

nongdate[2] = offset + 1;

return nongdate;

}/// /// 傳出y年m月d日對應的農曆.year0 .month1 .day2 .yearcyl3 .moncyl4 .daycyl5 .isleap6

///

///

///

///

///

private static long calelement(int y, int m, int d)

if (offset < 0)

nongdate[0] = i;

nongdate[3] = i - 1864;

leap = leapmonth(i); // 閏哪個月

nongdate[6] = 0;

for (i = 1; i < 13 && offset > 0; i++)

else

// 解除閏月

if (nongdate[6] == 1 && i == (leap + 1))

nongdate[6] = 0;

offset -= temp;

if (nongdate[6] == 0)

nongdate[4]++;

}if (offset == 0 && leap > 0 && i == leap + 1)

else

}if (offset < 0)

nongdate[1] = i;

nongdate[2] = offset + 1;

return nongdate;

}private static string getchinadate(int day)

return a;

}private static datetime sterm(int y,int n)

/// /// 獲取農曆

///

///

///

public static ***ate getchinadate(datetime dt)

}

公曆轉農曆

public string chineselunisolardate datetime adatatime 年月 甲乙丙丁戊己庚辛壬癸 year 4 10 子丑寅卯辰巳午未申酉戌亥 year 4 12 鼠牛虎兔龍蛇馬羊猴雞狗豬 year 4 12 month leapmonth 潤 無正二三四五六七...

C 公曆轉農曆演算法

using system using system.collections.generic using system.text 地支 private static string dizhi 十二生肖 private static string shengxiao 農曆日期 private stati...

公曆轉農曆函式

庫名 gton.h 程式by gshuang1 ifndef gton h 防止過載 define gton h uchar idata datenong 4 uchar code data1 公曆各個月的天數 uchar code days in a mon 2 12 uchar yearstyp...