程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> DecodeDate、DecodeTime ... DecodeDateTime ... 分解時間

DecodeDate、DecodeTime ... DecodeDateTime ... 分解時間

編輯:Delphi

SysUtils.DecodeDate();
SysUtils.DecodeDateFully();
SysUtils.DecodeTime();

DateUtils.DecodeDateTime();
DateUtils.DecodeDateDay();
DateUtils.DecodeDateWeek();
DateUtils.DecodeDateMonthWeek();
DateUtils.DecodeDayOfWeekInMonth();

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
  procedure FormCreate(Sender: TObject);
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

uses DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
var
 t: TDateTime;
 Year, Month, Day, Week: Word;
 Hour, Min, Sec, MSec: Word;
begin
 t := EncodeDateTime(2009, 5, 21, 11, 22, 33, 999);

 DecodeDate(t, Year, Month, Day);
 ShowMessageFmt('%d,%d,%d', [Year, Month, Day]); //2009,5,21

 DecodeDateFully(t, Year, Month, Day, Week);
  ShowMessageFmt('%d,%d,%d,%d', [Year, Month, Day, Week]); //2009,5,21,5; 最後的 5 表示周四

 DecodeTime(t, Hour, Min, Sec, MSec);
 ShowMessageFmt('%d,%d,%d,%d', [Hour, Min, Sec, MSec]); //11,22,33,999

 DecodeDateTime(t, Year, Month, Day, Hour, Min, Sec, MSec);
 ShowMessageFmt('%d,%d,%d,%d,%d,%d,%d', [Year, Month, Day, Hour, Min, Sec, MSec]); //2009,5,21,11,22,33,999

 DecodeDateDay(t, Year, Day);
 ShowMessageFmt('%d,%d', [Year, Day]); //2009,141; 2009 年第 141 天

 DecodeDateWeek(t, Year, Week, Day);
 ShowMessageFmt('%d,%d,%d', [Year, Week, Day]); //2009,21,4; 2009 年第 21 周, 周 4

 DecodeDateMonthWeek(t, Year, Month, Week, Day);
 ShowMessageFmt('%d,%d,%d,%d', [Year, Month, Week, Day]); //2009,5,3,4; 2009 年 5 月的第 3 周, 周 4

 DecodeDayOfWeekInMonth(t, Year, Month, Week, Day);
 ShowMessageFmt('%d,%d,%d,%d', [Year, Month, Week, Day]); //2009,5,3,4
end;


end.


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved