線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:51002
推到 Plurk!
推到 Facebook!

如何在一個表單中,顯示萬年曆!

答題得分者是:cmf
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-01-27 21:27:52 IP:61.217.xxx.xxx 未訂閱
如何在一個表單中,顯示萬年曆! 1.12月全部顯示、半年顯示。 2.任意設定,顯示月份。 3.農民曆怎麼顯示? 目前找不到,相關程式。我不想用別人的元件。 希望各位前輩幫幫忙!!
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-01-27 21:38:00 IP:61.70.xxx.xxx 未訂閱
 F SIR:       好久不見       http://delphi.ktop.com.tw/topic.php?topic_id=4267 農民曆 部份 找 DOS 程式 好像有 發表人 - cmf 於 2003/01/27 21:43:26
------
︿︿
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-01-27 22:02:24 IP:61.70.xxx.xxx 未訂閱
請問中國廿四節氣的標準時間如何計算呢?還有,請問怎樣進行陰陽曆換算呢?陰曆有的月是三十日,有的是二十九日,如何得知它這個月有多少日呢?(香港/匯基中學/五年級/譚丞相)      人們是依太陽在黃道上的位置,來決定二十四節氣的。整個黃道一圈是360°,360°÷24=15°,也就是以每15°為一節,而訂出二十四節氣。例如春分是在每年的3月20日或21日。不過,每個節氣並沒有固定在幾月幾日,大約有1~2天的誤差。至於計算,需要配合觀測來做,一般人不易學得。    陰曆算法,12個月大約比陽曆一年少11天,所以陰曆平均每2.8年,就要加上一次閏月,也就是某個月會過兩次,比方說有兩個八月,這樣才能配合年,因為我國的陰曆(或叫農曆),一年的長度和陽曆是一樣的。陰、陽曆之間的換算不容易,你可以買一本“萬年曆“,就可以查出兩者之間的換算。    一個朔望月的長度是29.5天,所以「大月」有30天,「小月」有29天,大致上大、小月是交互出現的。           發表人 - cmf 於 2003/01/27 22:17:19
------
︿︿
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-01-27 22:48:14 IP:218.163.xxx.xxx 未訂閱
歸納如下: 1、我國的農曆是一種陰陽曆1912年以前用。 2、我國的農曆強調逐年逐月推算。通過逐月推算後才知道某年某月是大月還 是小月;通過逐年推算後,才知道某年是閏年還是平年。 3、我國傳統曆法一直是陰陽曆和二十四氣並行,二十四氣適用於農業生產。 4、我國傳統曆法採用干支循環(六十甲子)為週期的紀時制度。 歷日的推算有兩條原則: 1、以月相定日序。即以日月合朔的日期和時刻來定每月的初一。 例如,如果今天6時5 分是日月合朔的時刻,則今天是初一。如果第二個 日月合朔落在第30天,那麼該月是小月(29天);如果落在第31天,那麼 該月是大月(30天); 2、以中氣定月序。 我國的舊歷把全年分二十四個節氣,其中單數的叫節氣,雙數的叫中氣。 以雨水所在的月為正月;以春分所在的月為定為二月;以此類推。 規定,平年有十二個月,閏年有十三個月,在沒有中氣的歷月叫閏月, 把閏月看成是前一月的重複,月序同上一月。 關於節氣與陽曆(國曆)的關係: 節氣是按太陽黃經來劃分的,在地球繞太陽轉的每15度為一個節氣,所以 節氣與國曆的日期是相對較固定的,每個國曆平年的節氣位置是固定的; 而國曆的閏年的節氣比平年的節氣的位置要前一日。如2000年(閏)其冬至 12月21日,而2001年(平)的冬至是22日的。 實現: 1、國曆中二十四節氣很簡單, 2、農曆要找到一個基準日(日月合朔的日期),才可按逐年逐月推算出日序 與月序;閏年與閏月。 3、再根據干支循環(六十甲子)定年就容易了。 ...程式怎麼規劃阿??
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-01-27 23:10:03 IP:218.163.xxx.xxx 未訂閱
謝謝cmf指教! 不過提供的是DOS版本。 分為主程式與引用單元 資源檔... ... 有沒有比較快的方式,一樣不用元件搞定萬年曆。
T.J.B
版主


發表:29
回覆:532
積分:497
註冊:2002-08-14

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-01-28 09:30:45 IP:61.220.xxx.xxx 未訂閱
可參考此篇 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=25382 天行健 君子當自強不息~~@.@
------
天行健
君子當自強不息~~@.@
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-01-28 14:45:06 IP:61.218.xxx.xxx 未訂閱
F SIR:            你開始做了嗎?    
------
︿︿
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-01-29 20:30:50 IP:61.217.xxx.xxx 未訂閱
先確定怎麼算日子就行, 每月有幾天就用大月小月,配合閏年檢查,譬如,(以下是虛擬碼) if month = 2 then if ((year mod 4 = 0) or (year mod 400 = 0)) and (year mod 100 != 0) then days := 29 else days := 28 end if else if (month = 4) or (month = 6) or (month = 9) or (month = 11) then days := 30 else days := 31 end if 然後,再借用2003年1月1日星期3當做基準, 2003年3月1日是星期幾? 答案是,經過上述if-else式子換算, 2003年1月有31天,2003年2月有28天,共為59天,59除7餘3, 所以2003年3月1日的星期數,是2003年1月1日的星期數加3(再除7餘6),為星期6. 知道這一天是星期6了,就很容易印出2003年3月1日的月曆.
cmf
尊榮會員


發表:84
回覆:918
積分:1032
註冊:2002-06-26

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-01-29 21:06:03 IP:61.70.xxx.xxx 未訂閱
f sir:       果然是大內高手         若以   2003年1月1日星期3當做基準      那     2000年1月1日是星期幾 ?                
------
︿︿
阿子
站務副站長


發表:120
回覆:230
積分:201
註冊:2002-03-18

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-01-29 23:58:07 IP:61.64.xxx.xxx 未訂閱
flyup 兄   這個萬年曆你看看對你有沒有幫助 http://delphi.ktop.com.tw/loadfile.php?TOPICID=7983704&CC=178556    從思考取勝一切~q
------
從思考取勝一切~q
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-01-30 12:28:16 IP:61.225.xxx.xxx 未訂閱
引言: flyup 兄 這個萬年曆你看看對你有沒有幫助 http://delphi.ktop.com.tw/loadfile.php?TOPICID=7983704&CC=178556 從思考取勝一切~q
下載位置: 台灣版(繁體) http://sean.wox.org/ap/calendar/calendar.htm 台灣宗教節日版(繁體) http://sean.wox.org/ap/calendar/calendarRG.htm Netscape 相容版本(繁體) http://sean.wox.org/ap/calendar/calendarJS.htm 中國版網站(簡體) http://21softs.com/ 香港版(繁體) http://sean.wox.org/ap/calendar/calendarHK.htm 美國中文版(繁體) http://sean.wox.org/ap/calendar/calendarUS.htm 註 1. 點選網址可直接瀏覽,或在網址上按滑鼠右鍵「另存目標」。 2. Netscape 版由於功能限制與佔有率低,所以自2000年7月後已不再更新程式碼。 3. 中國版漢化與當地節日資訊由 Sumyou (梅竹松) 維護。
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#12 引用回覆 回覆 發表時間:2003-01-30 21:01:37 IP:61.216.xxx.xxx 未訂閱
星期、干支、二十八宿計算公式 (按陽曆月日計算)    1. 求星期公式 星期=[5+A(實際天數)] mod 7    2. 干支計算公式 六十甲子干支序號,從1->59->0。 六十甲子干支序號=[23+A(實際天數)] mod 60    3. 二十八宿計算公式 二十八宿序號=[23+A(實際天數)] mod 28    4. 實際天數A的計算 A=B(基本天數)+C(閏日天數) B=(計算年-1)*365+(要計算到年的月日天數) 例:1984年2月1日的基本天數B=(1984-1)*365+(31+1)=723827(天),其中,31是1月為31天,1為2月1日為1天。 公元308年8月28日的基本天數B=(308-1)*365+(31+28+31+30+31+30+31+27)=112055+239=112294(天) 這裡的(要計算到年的月日天數),用的是國曆,月日天數的規則我好像小學就學過了。哈哈……    C=(計算年-1) div 4 -誤差修正值 + fixValue2 fixValue2為0或者1。常值為0,當年數為閏年(國曆閏年法)之中的3月1日之後的為1。    誤差修正值推算: 公元元年1月1日至1582年10月14日為0。 1582年10月15日至1699年12月31日為10。 從1701年1月1日起每增加一個世紀累加1,但能被400除盡的世紀不累加1。此方法推算即可。 ——有一個問題,1700年這一年的修正值應為多少呢?算法中正好沒有講到,但看來應該是10。    例1701年1月1日起誤差值為11,而1801年1月1日起誤差修正值為12,而1901年1月1日起誤差修正值為13, 但2001年誤差修正值仍為13,因為2000年能被400整除,故不累加。而2101年1月1日起誤差修正值為14。    5. 實例:1998.3.15的星期、干支與二十八宿 B=(1998-1)*365+(31+28+15)=728979 C=(1998-1) div 4 - 13 + 0 = 486 A=B+C=728979+486=729465 星期序號=(5+729465) mod 7=0,即為星期日 干支序號=(13+729465) mod 60=58,即為辛酉 二十八宿序號=(23+729465) mod 28=4,即為房    =================================================== 好可怕!還有一些其它公式……但好像有些參數不知道怎麼得到:    二十四節交節日算法: 用已知年的交接時辰加上22個小時35分,超過24要減去24,分數足60進1個小時,即得到8年後的各節交節時辰。 如2000年雨水交節時辰為16時22分,則2008年雨水交節時辰為14時52分。 因為16時22分+22時35分=38時57分。38-24=14時。 誰知道公元元年到公元八年的交節日,這個算法就可以實現了。——好像逆算法可以解決這個問題。誰試試?    農曆閏月算法: 農曆中,二十四節氣(十二節氣和十二中氣)的中氣落在月末的話,下個月就沒有中氣。農曆將這種有節(節氣)無氣(中氣)的月份規定為閏月。平均計算,19年有七個閏月。 但二十四個節氣的十二節氣和十二中氣是怎麼分的呢?我沒有資料,估記應該是一節氣一中氣這樣交叉。    
flyup
資深會員


發表:280
回覆:508
積分:385
註冊:2002-04-15

發送簡訊給我
#13 引用回覆 回覆 發表時間:2003-01-30 21:19:11 IP:61.216.xxx.xxx 未訂閱
{ Calendar Unit for Borland Delphi 5 (Other Version is not tested) Translated By Liu Ru Xu (liuruxu@21cn.com) 2001-1-4 Announcement from the original author: *************************************************************************** 致看到這些源程式碼的兄弟: 你好! 這本來是我為一個商業PDA產品開發的日曆程序,最近移植於PC機上, 所以算法 和資料部分是用純C++寫的,不涉及MFC,所有的程式碼都是以短節省存儲空間為主要目 的. 很高興你對這些程式碼有興趣,你可以隨意複製和使用些程式碼,唯一有一點小小的 願望:在你使用和複製給別人時,別忘註明這些程式碼作者:-)。程序程式碼也就罷了,後 面的資料可是我辛辛苦苦從萬年曆上找出來輸進去的。 如果你有什麼好的意見不妨Mail給我。 wangfei@hanwang.com.cn 或 wangfei@engineer.com.cn 2000年3月 **************************************************************************** }    unit Calend;    interface    uses SysUtils ;    const START_YEAR=1901; END_YEAR=2050;    //返回iYear年iMonth月的天數 1年1月 --- 65535年12月 function MonthDays(iYear,iMonth:Word):Word;    //返回陰曆iLunarYer年陰曆iLunarMonth月的天數,如果iLunarMonth為閏月, //高字為第二個iLunarMonth月的天數,否則高字為0 1901年1月---2050年12月 function LunarMonthDays(iLunarYear,iLunarMonth:Word):Longword;    //返回陰曆iLunarYear年的總天數 1901年1月---2050年12月 function LunarYearDays(iLunarYear:Word):Word;    //返回陰曆iLunarYear年的閏月月份,如沒有返回0 1901年1月---2050年12月 function GetLeapMonth(iLunarYear:Word):Word;    //把iYear年格式化成天干記年法表示的字串 procedure FormatLunarYear(iYear:Word;var pBuffer:string);overload; function FormatLunarYear(iYear:Word):string;overload;    //把iMonth格式化成中文字串 procedure FormatMonth(iMonth:Word;var pBuffer:string;bLunar:Boolean=True);overload; function FormatMonth(iMonth:Word;bLunar:Boolean=True):string;overload;    //把iDay格式化成中文字串 procedure FormatLunarDay(iDay:Word;var pBuffer:string);overload; function FormatLunarDay(iDay:Word):string;overload;    //計算國曆兩個日期間相差的天數 1年1月1日 --- 65535年12月31日 function CalcDateDiff(iEndYear,iEndMonth,iEndDay:Word;iStartYear:Word=START_YEAR;iStartMonth:Word=1;iStartDay:Word=1):Longword;overload; function CalcDateDiff(EndDate,StartDate:TDateTime):Longword;overload;    //計算國曆iYear年iMonth月iDay日對應的陰曆日期,返回對應的陰曆節氣 0-24 //1901年1月1日---2050年12月31日    function GetLunarHolDay(InDate:TDateTime):string;overload; function GetLunarHolDay(iYear,iMonth,iDay:Word):string;overload;    //private function--------------------------------------    //計算從1901年1月1日過iSpanDays天後的陰曆日期 procedure l_CalcLunarDate(var iYear,iMonth,iDay:Word;iSpanDays:Longword);    //計算國曆iYear年iMonth月iDay日對應的節氣 0-24,0表不是節氣 function l_GetLunarHolDay(iYear,iMonth,iDay:Word):Word;    implementation    var //模組gLunarDay存入陰曆1901年到2100年每年中的月天數信息, //陰曆每月只能是29或30天,一年用12(或13)個二進制位表示,對應位為1表30天,否則為29天 gLunarMonthDay:array[0..149] of Word=( //測試資料只有1901.1.1 --2050.12.31 $4ae0, $a570, $5268, $d260, $d950, $6aa8, $56a0, $9ad0, $4ae8, $4ae0, //1910 $a4d8, $a4d0, $d250, $d548, $b550, $56a0, $96d0, $95b0, $49b8, $49b0, //1920 $a4b0, $b258, $6a50, $6d40, $ada8, $2b60, $9570, $4978, $4970, $64b0, //1930 $d4a0, $ea50, $6d48, $5ad0, $2b60, $9370, $92e0, $c968, $c950, $d4a0, //1940 $da50, $b550, $56a0, $aad8, $25d0, $92d0, $c958, $a950, $b4a8, $6ca0, //1950 $b550, $55a8, $4da0, $a5b0, $52b8, $52b0, $a950, $e950, $6aa0, $ad50, //1960 $ab50, $4b60, $a570, $a570, $5260, $e930, $d950, $5aa8, $56a0, $96d0, //1970 $4ae8, $4ad0, $a4d0, $d268, $d250, $d528, $b540, $b6a0, $96d0, $95b0, //1980 $49b0, $a4b8, $a4b0, $b258, $6a50, $6d40, $ada0, $ab60, $9370, $4978, //1990 $4970, $64b0, $6a50, $ea50, $6b28, $5ac0, $ab60, $9368, $92e0, $c960, //2000 $d4a8, $d4a0, $da50, $5aa8, $56a0, $aad8, $25d0, $92d0, $c958, $a950, //2010 $b4a0, $b550, $b550, $55a8, $4ba0, $a5b0, $52b8, $52b0, $a930, $74a8, //2020 $6aa0, $ad50, $4da8, $4b60, $9570, $a4e0, $d260, $e930, $d530, $5aa0, //2030 $6b50, $96d0, $4ae8, $4ad0, $a4d0, $d258, $d250, $d520, $daa0, $b5a0, //2040 $56d0, $4ad8, $49b0, $a4b8, $a4b0, $aa50, $b528, $6d20, $ada0, $55b0); //2050    //模組gLanarMonth存放陰曆1901年到2050年閏月的月份,如沒有則為0,每字節存兩年 gLunarMonth:array[0..74] of Byte=( $00, $50, $04, $00, $20, //1910 $60, $05, $00, $20, $70, //1920 $05, $00, $40, $02, $06, //1930 $00, $50, $03, $07, $00, //1940 $60, $04, $00, $20, $70, //1950 $05, $00, $30, $80, $06, //1960 $00, $40, $03, $07, $00, //1970 $50, $04, $08, $00, $60, //1980 $04, $0a, $00, $60, $05, //1990 $00, $30, $80, $05, $00, //2000 $40, $02, $07, $00, $50, //2010 $04, $09, $00, $60, $04, //2020 $00, $20, $60, $05, $00, //2030 $30, $b0, $06, $00, $50, //2040 $02, $07, $00, $50, $03); //2050    //模組gLanarHoliDay存放每年的二十四節氣對應的陽曆日期 //每年的二十四節氣對應的陽曆日期幾乎固定,平均分佈於十二個月中 // 1月 2月 3月 4月 5月 6月 //小寒 大寒 立春 雨水 驚蟄 春分 清明 谷雨 立夏 小滿 芒種 夏至 // 7月 8月 9月 10月 11月 12月 //小暑 大暑 立秋 處暑 白露 秋分 寒露 霜降 立冬 小雪 大雪 冬至 {********************************************************************************* 節氣無任何確定規律,所以只好存表,要節省空間,所以.... **********************************************************************************} //資料格式說明: //如1901年的節氣為 // 1月 2月 3月 4月 5月 6月 7月 8月 9月 10月 11月 12月 // 6, 21, 4, 19, 6, 21, 5, 21, 6,22, 6,22, 8, 23, 8, 24, 8, 24, 8, 24, 8, 23, 8, 22 // 9, 6, 11,4, 9, 6, 10,6, 9,7, 9,7, 7, 8, 7, 9, 7, 9, 7, 9, 7, 8, 7, 15 //上面第一行資料為每月節氣對應日期,15減去每月第一個節氣,每月第二個節氣減去15得第二行 // 這樣每月兩個節氣對應資料都小於16,每月用一個字節存放,高位存放第一個節氣資料,低位存放 //第二個節氣的資料,可得下表 gLunarHolDay:array[0..1799] of Byte=( $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1901 $96, $A4, $96, $96, $97, $87, $79, $79, $79, $69, $78, $78, //1902 $96, $A5, $87, $96, $87, $87, $79, $69, $69, $69, $78, $78, //1903 $86, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $78, $87, //1904 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1905 $96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1906 $96, $A5, $87, $96, $87, $87, $79, $69, $69, $69, $78, $78, //1907 $86, $A5, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1908 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1909 $96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1910 $96, $A5, $87, $96, $87, $87, $79, $69, $69, $69, $78, $78, //1911 $86, $A5, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1912 $95, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1913 $96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $78, //1914 $96, $A5, $97, $96, $97, $87, $79, $79, $69, $69, $78, $78, //1915 $96, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1916 $95, $B4, $96, $A6, $96, $97, $78, $79, $78, $69, $78, $87, //1917 $96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $77, //1918 $96, $A5, $97, $96, $97, $87, $79, $79, $69, $69, $78, $78, //1919 $96, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1920 $95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $87, //1921 $96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $77, //1922 $96, $A4, $96, $96, $97, $87, $79, $79, $69, $69, $78, $78, //1923 $96, $A5, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1924 $95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $87, //1925 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1926 $96, $A4, $96, $96, $97, $87, $79, $79, $79, $69, $78, $78, //1927 $96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1928 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1929 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1930 $96, $A4, $96, $96, $97, $87, $79, $79, $79, $69, $78, $78, //1931 $96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1932 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1933 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1934 $96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1935 $96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1936 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1937 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1938 $96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1939 $96, $A5, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1940 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1941 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1942 $96, $A4, $96, $96, $97, $97, $79, $79, $79, $69, $78, $78, //1943 $96, $A5, $96, $A5, $A6, $96, $88, $78, $78, $78, $87, $87, //1944 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1945 $95, $B4, $96, $A6, $97, $97, $78, $79, $78, $69, $78, $77, //1946 $96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $78, //1947 $96, $A5, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1948 $A5, $B4, $96, $A5, $96, $97, $88, $79, $78, $79, $77, $87, //1949 $95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $77, //1950 $96, $B4, $96, $A6, $97, $97, $79, $79, $79, $69, $78, $78, //1951 $96, $A5, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1952 $A5, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1953 $95, $B4, $96, $A5, $96, $97, $78, $79, $78, $68, $78, $87, //1954 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1955 $96, $A5, $A5, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1956 $A5, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1957 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1958 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1959 $96, $A4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1960 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1961 $96, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1962 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1963 $96, $A4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1964 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1965 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1966 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1967 $96, $A4, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1968 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1969 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1970 $96, $B4, $96, $A6, $97, $97, $78, $79, $79, $69, $78, $77, //1971 $96, $A4, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1972 $A5, $B5, $96, $A5, $A6, $96, $88, $78, $78, $78, $87, $87, //1973 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1974 $96, $B4, $96, $A6, $97, $97, $78, $79, $78, $69, $78, $77, //1975 $96, $A4, $A5, $B5, $A6, $A6, $88, $89, $88, $78, $87, $87, //1976 $A5, $B4, $96, $A5, $96, $96, $88, $88, $78, $78, $87, $87, //1977 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $78, $87, //1978 $96, $B4, $96, $A6, $96, $97, $78, $79, $78, $69, $78, $77, //1979 $96, $A4, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1980 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $77, $87, //1981 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1982 $95, $B4, $96, $A5, $96, $97, $78, $79, $78, $69, $78, $77, //1983 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //1984 $A5, $B4, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //1985 $A5, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //1986 $95, $B4, $96, $A5, $96, $97, $88, $79, $78, $69, $78, $87, //1987 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //1988 $A5, $B4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1989 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //1990 $95, $B4, $96, $A5, $86, $97, $88, $78, $78, $69, $78, $87, //1991 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //1992 $A5, $B3, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //1993 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1994 $95, $B4, $96, $A5, $96, $97, $88, $76, $78, $69, $78, $87, //1995 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //1996 $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //1997 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //1998 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //1999 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2000 $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2001 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2002 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //2003 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2004 $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2005 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2006 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $69, $78, $87, //2007 $96, $B4, $A5, $B5, $A6, $A6, $87, $88, $87, $78, $87, $86, //2008 $A5, $B3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2009 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2010 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $78, $87, //2011 $96, $B4, $A5, $B5, $A5, $A6, $87, $88, $87, $78, $87, $86, //2012 $A5, $B3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2013 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2014 $95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //2015 $95, $B4, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86, //2016 $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2017 $A5, $B4, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2018 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //2019 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $86, //2020 $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2021 $A5, $B4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //2022 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //2023 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2024 $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2025 $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2026 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2027 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2028 $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2029 $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2030 $A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2031 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2032 $A5, $C3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $86, //2033 $A5, $B3, $A5, $A5, $A6, $A6, $88, $78, $88, $78, $87, $87, //2034 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2035 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2036 $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2037 $A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2038 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2039 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2040 $A5, $C3, $A5, $B5, $A5, $A6, $87, $88, $87, $78, $87, $86, //2041 $A5, $B3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2042 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2043 $95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $88, $87, $96, //2044 $A5, $C3, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86, //2045 $A5, $B3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2046 $A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2047 $95, $B4, $A5, $B4, $A5, $A5, $97, $87, $87, $88, $86, $96, //2048 $A4, $C3, $A5, $A5, $A5, $A6, $97, $87, $87, $78, $87, $86, //2049 $A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $78, $78, $87, $87); //2050    function MonthDays(iYear,iMonth:Word):Word; begin case iMonth of 1,3,5,7,8,10,12: Result:=31; 4,6,9,11: Result:=30; 2://如果是閏年 if IsLeapYear(iYear) then Result:=29 else Result:=28 else Result:=0; end; end;    function GetLeapMonth(iLunarYear:Word):Word; var Flag:Byte; begin Flag:=gLunarMonth[(iLunarYear-START_YEAR) div 2]; if (iLunarYear-START_YEAR) mod 2=0 then Result:=Flag shr 4 else Result:=Flag and $0F; end;    function LunarMonthDays(iLunarYear,iLunarMonth:Word):Longword; var Height,Low:Word; iBit:Integer; begin if iLunarYearGetLeapMonth(iLunarYear)) and (GetLeapMonth(iLunarYear)>0) then Dec(iBit); if (gLunarMonthDay[iLunarYear-START_YEAR] and (1 shl iBit))>0 then Inc(Low); if iLunarMonth=GetLeapMonth(iLunarYear) then if (gLunarMonthDay[iLunarYear-START_YEAR] and (1 shl (iBit-1)))>0 then Height:=30 else Height:=29; Result:=MakeLong(Low,Height); end; function LunarYearDays(iLunarYear:Word):Word; var Days,i:Word; tmp:Longword; begin Days:=0; for i:=1 to 12 do begin tmp:=LunarMonthDays(iLunarYear,i); Days:=Days HiWord(tmp); Days:=Days LoWord(tmp); end; Result:=Days; end; procedure FormatLunarYear(iYear:Word;var pBuffer:string); var szText1,szText2,szText3:string; begin szText1:='甲乙丙丁戊己庚辛壬癸'; szText2:='子丑寅卯辰巳午未申酉戌亥'; szText3:='鼠牛虎免龍蛇馬羊猴雞狗豬'; pBuffer:=Copy(szText1,((iYear-4) mod 10)*2 1,2); pBuffer:=pBuffer Copy(szText2,((iYear-4) mod 12)*2 1,2); pBuffer:=pBuffer ' '; pBuffer:=pBuffer Copy(szText3,((iYear-4) mod 12)*2 1,2); pBuffer:=pBuffer '年'; end; function FormatLunarYear(iYear:Word):string; var pBuffer:string; begin FormatLunarYear(iYear,pBuffer); Result:=pBuffer; end; procedure FormatMonth(iMonth:Word;var pBuffer:string;bLunar:Boolean); var szText:string; begin if (not bLunar) and (iMonth=1) then begin pBuffer:=' 一月'; Exit; end; szText:='正二三四五六七八九十'; if iMonth<=10 then begin pBuffer:=' '; pBuffer:=pBuffer Copy(szText,(iMonth-1)*2 1,2); pBuffer:=pBuffer '月'; Exit; end; if iMonth=11 then pBuffer:='十一' else pBuffer:='十二'; pBuffer:=pBuffer '月'; end; function FormatMonth(iMonth:Word;bLunar:Boolean):string; var pBuffer:string; begin FormatMonth(iMonth,pBuffer,bLunar); Result:=pBuffer; end; procedure FormatLunarDay(iDay:Word;var pBuffer:string); var szText1,szText2:string; begin szText1:='初十廿三'; szText2:='一二三四五六七八九十'; if (iDay<>20) and (iDay<>30) then begin pBuffer:=Copy(szText1,((iDay-1) div 10)*2 1,2); pBuffer:=pBuffer Copy(szText2,((iDay-1) mod 10)*2 1,2); end else begin pBuffer:=Copy(szText1,(iDay div 10)*2 1,2); pBuffer:=pBuffer '十'; end; end; function FormatLunarDay(iDay:Word):string; var pBuffer:string; begin FormatLunarDay(iDay,pBuffer); Result:=pBuffer; end; function CalcDateDiff(iEndYear,iEndMonth,iEndDay:Word;iStartYear:Word;iStartMonth:Word;iStartDay:Word):Longword; begin Result:=Trunc(EncodeDate(iEndYear,iEndMonth,iEndDay)-EncodeDate(iStartYear,iStartMonth,iStartDay)); end; function CalcDateDiff(EndDate,StartDate:TDateTime):Longword; begin Result:=Trunc(EndDate-StartDate); end; procedure l_CalcLunarDate(var iYear,iMonth,iDay:Word;iSpanDays:Longword); var tmp:Longword; begin //陽曆1901年2月19日為陰曆1901年正月初一 //陽曆1901年1月1日到2月19日共有49天 if iSpanDays<49 then begin iYear:=START_YEAR-1; if iSpanDays<19 then begin iMonth:=11; iDay:=11 Word(iSpanDays); end else begin iMonth:=12; iDay:=Word(iSpanDays)-18; end; Exit; end; //下面從陰曆1901年正月初一算起 iSpanDays:=iSpanDays-49; iYear:=START_YEAR; iMonth:=1; iDay:=1; //計算年 tmp:=LunarYearDays(iYear); while iSpanDays>=tmp do begin iSpanDays:=iSpanDays-tmp; Inc(iYear); tmp:=LunarYearDays(iYear); end; //計算月 tmp:=LoWord(LunarMonthDays(iYear,iMonth)); while iSpanDays>=tmp do begin iSpanDays:=iSpanDays-tmp; if iMonth=GetLeapMonth(iYear) then begin tmp:=HiWord(LunarMonthDays(iYear,iMonth)); if iSpanDays15 then Result:=(iMonth-1)*2 2 else Result:=(iMonth-1)*2 1 else Result:= 0; end; function GetLunarHolDay(InDate:TDateTime):string; var i,iYear,iMonth,iDay:Word; begin DecodeDate(InDate,iYear,iMonth,iDay); i:=l_GetLunarHolDay(iYear,iMonth,iDay); case i of 1:Result:='小 寒'; 2:Result:='大 寒'; 3:Result:='立 春'; 4:Result:='雨 水'; 5:Result:='驚 蟄'; 6:Result:='春 分'; 7:Result:='清 明'; 8:Result:='谷 雨'; 9:Result:='立 夏'; 10:Result:='小 滿'; 11:Result:='芒 種'; 12:Result:='夏 至'; 13:Result:='小 暑'; 14:Result:='大 暑'; 15:Result:='立 秋'; 16:Result:='處 暑'; 17:Result:='白 露'; 18:Result:='秋 分'; 19:Result:='寒 露'; 20:Result:='霜 降'; 21:Result:='立 冬'; 22:Result:='小 雪'; 23:Result:='大 雪'; 24:Result:='冬 至'; else l_CalcLunarDate(iYear,iMonth,iDay,CalcDateDiff(InDate,EncodeDate(START_YEAR,1,1))); Result := trim(FormatMonth(iMonth) FormatLunarDay(iDay)); end; end; function GetLunarHolDay(iYear,iMonth,iDay:Word):string; begin Result:=GetLunarHolDay(EncodeDate(iYear,iMonth,iDay)); end; end.
st
一般會員


發表:11
回覆:21
積分:11
註冊:2004-07-02

發送簡訊給我
#14 引用回覆 回覆 發表時間:2004-10-28 13:49:19 IP:211.22.xxx.xxx 未訂閱
Calendar Unit for Borland Delphi 5 (Other Version is not tested) Translated By Liu Ru Xu (liuruxu@21cn.com) 2001-1-4 Announcement from the original author: *************************************************************************** 致看到這些源程式碼的兄弟: 你好! 這本來是我為一個商業PDA產品開發的日曆程序,最近移植於PC機上, 所以算法 和資料部分是用純C++寫的,不涉及MFC,所有的程式碼都是以短節省存儲空間為主要目的. 很高興你對這些程式碼有興趣,你可以隨意複製和使用些程式碼,唯一有一點小小的願望:在你使用和複製給別人時,別忘註明這些程式碼作者:-)。程序程式碼也就罷了,後面的資料可是我辛辛苦苦從萬年曆上找出來輸進去的。 如果你有什麼好的意見不妨Mail給我。 wangfei@hanwang.com.cn 或 wangfei@engineer.com.cn 2000年3月 ===================================================================== 您好 我寫了一個"排八字的萬年曆" 核算農曆的部份是從 java 中轉寫的 當我看了您的 source code 後應該 可以確定是別人從您這改寫成 java 的 在此我先向您至上感謝之意, < >< > 請問我是否可以上傳我的
esp_pzj
初階會員


發表:32
回覆:70
積分:40
註冊:2007-02-09

發送簡訊給我
#15 引用回覆 回覆 發表時間:2012-09-04 00:39:26 IP:125.224.xxx.xxx 訂閱

感謝flyup提供萬年曆函數,請問下列兩個問題如何修正,謝謝!

[code delphi]
function LunarMonthDays(iLunarYear,iLunarMonth:Word):Longword;
var
Height,Low:Word;
iBit:Integer;
begin
if iLunarYear begin
Result:=30;
Exit;
end;
Height:=0;
Low:=29;
iBit:=16-iLunarMonth;
if (iLunarMonth>GetLeapMonth(iLunarYear)) and (GetLeapMonth(iLunarYear)>0) then
Dec(iBit);
if (gLunarMonthDay[iLunarYear-START_YEAR] and (1 shl iBit))>0 then
Inc(Low);
if iLunarMonth=GetLeapMonth(iLunarYear) then
if (gLunarMonthDay[iLunarYear-START_YEAR] and (1 shl (iBit-1)))>0 then
Height:=30
else
Height:=29;
Result:=MakeLong(Low,Height);

end;
[/code]

如件修正
if iLunarYear begin
Result:=30;
Exit;
end;


[code delphi]
procedure l_CalcLunarDate(var iYear,iMonth,iDay:Word;iSpanDays:Longword);
var
tmp:Longword;
begin
//陽曆1901年2月19日為陰曆1901年正月初一
//陽曆1901年1月1日到2月19日共有49天
if iSpanDays<49 then
begin
iYear:=START_YEAR-1;
if iSpanDays<19 then
begin
iMonth:=11;
iDay:=11 Word(iSpanDays);
end
else
begin
iMonth:=12;
iDay:=Word(iSpanDays)-18;
end;
Exit;
end;
//下面從陰曆1901年正月初一算起
iSpanDays:=iSpanDays-49;
iYear:=START_YEAR;
iMonth:=1;
iDay:=1;
//計算年
tmp:=LunarYearDays(iYear);
while iSpanDays>=tmp do
begin
iSpanDays:=iSpanDays-tmp;
Inc(iYear);
tmp:=LunarYearDays(iYear);
end;
//計算月

tmp:=LoWord(LunarMonthDays(iYear,iMonth));
while iSpanDays>=tmp do
begin
iSpanDays:=iSpanDays-tmp;
if iMonth=GetLeapMonth(iYear) then
begin
tmp:=HiWord(LunarMonthDays(iYear,iMonth));
procedure l_CalcLunarDate(var iYear,iMonth,iDay:Word;iSpanDays:Longword);
var
tmp:Longword;
begin
//陽曆1901年2月19日為陰曆1901年正月初一
//陽曆1901年1月1日到2月19日共有49天
if iSpanDays<49 then
begin
iYear:=START_YEAR-1;
if iSpanDays<19 then
begin
iMonth:=11;
iDay:=11 Word(iSpanDays);
end
else
begin
iMonth:=12;
iDay:=Word(iSpanDays)-18;
end;
Exit;
end;
//下面從陰曆1901年正月初一算起
iSpanDays:=iSpanDays-49;
iYear:=START_YEAR;
iMonth:=1;
iDay:=1;
//計算年
tmp:=LunarYearDays(iYear);
while iSpanDays>=tmp do
begin
iSpanDays:=iSpanDays-tmp;
Inc(iYear);
tmp:=LunarYearDays(iYear);
end;
//計算月

tmp:=LoWord(LunarMonthDays(iYear,iMonth));
while iSpanDays>=tmp do
begin
iSpanDays:=iSpanDays-tmp;
if iMonth=GetLeapMonth(iYear) then
begin
tmp:=HiWord(LunarMonthDays(iYear,iMonth));
if iSpanDays iSpanDays:=iSpanDays-tmp;
end;
Inc(iMonth);
tmp:=LoWord(LunarMonthDays(iYear,iMonth));
end;
//計算日
iDay:=iDay Word(iSpanDays);
end;
end;
Inc(iMonth);
tmp:=LoWord(LunarMonthDays(iYear,iMonth));
end;
//計算日
iDay:=iDay Word(iSpanDays);
end;

[/code]

如件修正
if iSpanDays iSpanDays:=iSpanDays-tmp;



------
學藝不精 謝多多指教
編輯記錄
esp_pzj 重新編輯於 2012-09-03 10:41:37, 註解 無‧
系統時間:2024-04-26 22:19:32
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!