全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2814
推到 Plurk!
推到 Facebook!

Delphi中如何知道每年的中秋節是幾月幾號?

尚未結案
shelly.hong
一般會員


發表:6
回覆:1
積分:1
註冊:2003-01-10

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-07-12 16:25:39 IP:203.75.xxx.xxx 未訂閱
請教各位大大: 如何知道每年的中秋節是幾月幾號呢?
chiehmin
高階會員


發表:13
回覆:134
積分:134
註冊:2002-05-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-07-12 16:55:51 IP:61.221.xxx.xxx 未訂閱
參考看看..民國元年到100年..【農曆轉國曆】..        
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;    type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure Lunar2Solar(LYear, LMonth, LDay: integer; var SYear, SMonth,
      SDay: integer);
    procedure ProcessMagicStr(yy: integer);
    procedure CovertLunarMonth(magicno: integer);
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1: TForm1;
  LMDay : array[1..13] of integer;
  InterMonth, InterMonthDays, SLRangeDay : integer;    const
  SMDay : array[1..12] of integer = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  SMDay2 : array[1..12] of integer = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);      LongLife : array[1..100] of string[9] = (
    '132637048', '133365036', '053365225', '132900044', '131386034', '022778122', //6
    '132395041', '071175231', '131175050', '132635038', '052891127', '131701046', //12
    '131748035', '042741223', '130694043', '132391032', '021327122', '131175040', //18
    '061623129', '133402047', '133402036', '051769125', '131453044', '130694034', //24
    '032158223', '132350041', '073213230', '133221049', '133402038', '063466226', //30
    '132901045', '131130035', '042651224', '130605043', '132349032', '023371121', //36
    '132709040', '072901128', '131738047', '132901036', '051333226', '131210044', //42
    '132651033', '031111223', '131323042', '082714130', '133733048', '131706038', //48
    '062794127', '132741045', '131206035', '042734124', '132647043', '131318032', //54
    '033878120', '133477039', '071461129', '131386047', '132413036', '051245126', //60
    '131197045', '132637033', '043405122', '133365041', '083413130', '132900048', //66
    '132922037', '062394227', '132395046', '131179035', '042711124', '132635043', //72
    '102855132', '131701050', '131748039', '062804128', '132742047', '132359036', //78
    '051199126', '131175045', '131611034', '031866122', '133749040', '081717130', //84
    '131452049', '132742037', '052413127', '132350046', '133222035', '043477123', //90
    '133402042', '133493031', '021877121', '131386039', '072747128', '130605048', //96
    '132349037', '053243125', '132709044', '132890033' );    implementation    {$R *.dfm}    procedure TForm1.Lunar2Solar(LYear, LMonth, LDay : integer; var SYear, SMonth, SDay : integer);
var
   i, day, j : integer;
   SMDay3: Array[1..12] of Integer;
begin
     day := 0;
     SYear := LYear;
     For j := 1 to 12 do
     begin
       SMDay3[j] := SMDay[j];
       if isLeapYear(SYear 1911) then
          SMDay3[j] := SMDay2[j];
     end;
     processmagicstr(SYear);
     if LMonth < 0 then
        day := LMDay[InterMonth];
     if LMonth <> 1 then
        for i := 1 to LMonth-1 do
            day := day   LMDay[i];
     day := day   LDay   SLRangeDay;
     if (InterMonth <> 13) and (InterMonth < LMonth) then
        day := day   InterMonthDays;
     for i := 1 to 12 do begin
         day := day - SMDay3[i];
         if day <= 0 then
            break;
     end;
     if day > 0 then begin
        SYear := SYear   1;
        For j := 1 to 12 do
        begin
          SMDay3[j] := SMDay[j];
          if isLeapYear(SYear 1911) then
             SMDay3[j] := SMDay2[j];
        end;
        for i := 1 to 12 do begin
            day := day - SMDay3[i];
            if day <= 0 then
               break;
        end;
     end;
     day := day   SMDay3[i];
     SMonth := i;
     SDay := day;
end;    procedure TForm1.ProcessMagicStr(yy : integer);
var
   magicstr : string;
   dsize, LunarMonth : integer;
begin
  magicstr := LongLife[yy];
  InterMonth := StrToInt(Copy(magicstr, 1, 2));
  LunarMonth := StrToInt(copy(magicstr, 3, 4));
  CovertLunarMonth(LunarMonth);
  dsize := StrToInt(Copy(magicstr, 7, 1));
  case dsize of
    0: InterMonthDays := 0;
    1: InterMonthDays := 29;
    2: InterMonthDays := 30;
  end;      SLRangeDay := StrToInt(Copy(Magicstr, 8, 2));
end;    procedure TForm1.CovertLunarMonth(magicno : integer);
var
   i, size, m : integer;
begin
  m := magicno;
  For i := 12 downto 1 do
  begin
    size := m mod 2;
    if size = 0 then
      LMDay[i] := 29
    else
      LMDay[i] := 30;        m := m div 2;
  end;
end;    procedure TForm1.Button1Click(Sender: TObject);
var
  y, m, d: Integer;
begin
  Lunar2Solar(93, 8, 15, y, m, d);      ShowMessage(IntToStr(y)   '/'   IntToStr(m)   '/'   IntToStr(d));
end;    end.
系統時間:2024-06-29 4:53:21
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!