Guan caucained lunar calendar (C version)

zhaozj2021-02-16  57

Some time to do software, the software wrote a function of the Queue calendar. At present, I will give you a reference. Interested friends can further improve their functions.

/ * ------------ Lunar conversion function ----------- * / char * getdayof (psystemtime pst) {/ * day dry name * / const char * ctiangan [] = {"Jia", "B", "C", "Ding", "He", "Geng", "Xin", "", ""}; / * Site Name * / Const Char * cdizhi [] = {"子", "ugly", "寅", "", "", "", "noon", "no", "Shen", "", "" , "Hai"}; / * genus Name * / const char * cshuxiang [] = {"Rat", "Niu", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Sheep" "" Monkey "," Chicken "," Dog "," Pig "}; / * Lunar Date |" First "," First "," First Second ", Three "," First Four "," First Fifth "," First Six "," First Seventh "," First Eight "," Jijiu "," Early Ten "," Twelve "," Twelve "," Ten " Three "," 14 "," 15 "," 16 "," 17 "," 18 "," 19 "," 20 "," 一 "," 廿 "," Three "," 四 "," 五 "," 六 "," 七 "," 廿 八 "," 九 "," thirty "}; / * Lunar month * / const char * cmonname [] = {"*", "Positive", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "ten A "" La "}

/ * The number of days before the question * / const Int Wmonthadd [12] = {0, 31, 59, 90, 123, 251, 181, 212, 243, 273, 304, 334}; / * Lunar Data * / Const Int Wnonglidata [100] = {2635, 333387, 1701, 1748, 267701 , 694, 2391, 133423, 1175, 396438, 3402, 3749, 331177, 1153, 694, 3226, 2350, 465197, 3221, 3402, 400, 21, 2905, 2349, 137515, 2709, 464533, 1738 , 2901, 330421, 1242, 2651, 199255, 1323, 529706, 3733, 1706, 398762, 2741, 1106, 267438, 2747, 461653, 1386, 2413, 330077, 1197, 2637, 268877, 3365 , 531109, 2900, 2922, 398042, 2395, 1179, 267415, 2635, 661067, 1701, 1748, 398772, 2175, 2191, 3300, 3749, 527717, 1452, 2742, 332397, 2350, 3222 , 268949,3402,3493,133973,1386,464219,605,2349,334123,2709, 2890,267946,2773,592565,1210,2651,395863,1323,2707,265877}; static int wCurYear, wCurMonth, wCurDay; Static int NTHEDATE, NISEND, M, K, N, I, Nbit; Tchar sznongli [30], sznongliday [10], szshuxiang [10]; / * --- Take the current Queen, month, day --- * / WCURYEAR = PST-> Wyear; wcurmonth = PST-> WMONTH; wcurday = PST-> wday; / * --- Calculated to initial time 1921 2 Number of days on the 8th: 1921-2-8 (first month of the first) --- * / nthedate = (WCURYEAR - 1921) * 365 (WCURYEAR - 1921) / 4 WCURDAY WMONTHADD [WCURMONTH - 1] - 38; IF (wcuryear% 4)) && (wcurmonth> 2)) nthedate = nthedate 1; / * - calculate the lunar day, the land, month, day --- * / nisnd = 0; m = 0; while (NiSend! = 1) {IF (Wnonglidata [M] <4095) k = 11; Else K = 12; n = k; while (n> = 0) {// Gets the nub-bits of WnongLidata (M) Value nbit = wnonglidata [m]; for (i = 1; i

Nbit = nbit% 2;

IF (nthedate <= (29 nbit)) {nisnd = 1; Break;}

nthedate = nthedate - 29 - nbit; n = n - 1; = = m 1;} wcuryear = 1921 m; wcurmonth = k - n 1; wcurday = nthedate; if (k = = 12) {IF (wcurmonth == Wnonglidata [m] / 65536 1) wcurmonth = 1 - wcurmonth; Else IF (wcurmonth> Wnonglidata [m] / 65536 1) wcurmonth = wcurmonth - 1;} / * - generate Lunar calendar, land, belly, genus ==> Wnongli - * / wsprintf (szshuxiang, "% s", cshuxiang [(wcuryear - 4)% 60)% 12]); WSPrintf (sznongli, "% s (% s% S) Year ", SZSHUXIANG, CTIANGAN [(WCURYEAR - 4)% 60)% 10], CDIZHI [(WCURYEAR - 4)% 60)% 12]);

/ * - Generate a lunar month, day ==> Wnongliday - * / if (wcurmonth <1) WSPrintf (sznongliday, "% s", cmonname [-1 * wcurmonth]); Else Strcpy (sznongliday, cmonname [wcurmonth ]);

Strcat (Sznongliday, "Month"); strcat (sznongliday, cdayname [wcurday]); returnction strcat (sznongli, sznongliday);

}

转载请注明原文地址:https://www.9cbs.com/read-24258.html

New Post(0)