其他分享
首页 > 其他分享> > DecodeDate、DecodeTime ... DecodeDateTime ... 分解时间

DecodeDate、DecodeTime ... DecodeDateTime ... 分解时间

作者:互联网

DecodeDate、DecodeTime ... DecodeDateTime ... 分解时间

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.


DateUtils-Function
posted on 2009-05-21 10:37  万一  阅读(5507)  评论(0)  编辑  收藏

标签:Week,...,DecodeDate,DecodeTime,Month,ShowMessageFmt,Year,2009,Day
来源: https://blog.51cto.com/u_14617575/2748112