zoukankan      html  css  js  c++  java
  • Delphi DecodeDate和EncodeDate 拆分和聚合时间函数的用法

     

     

    SysUtils
    procedure DecodeData(Date: TDateTime; var Year, Month, Day: Word);
    DecodeDate打断TdateTime成为年月日的值。
    DecodeDate打断由Date参数说明的值成为年月日的值。
    如果TDateTime值是小于或等于0,那么返回的年月日值为0;

    这个例子使用一个按纽和两个标签,当按击按钮时,当前的日期和时间就会出现在两个标签的标题中显示。
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Present: TDateTime;
    Year, Month, Day, Hour, Min, Sec, MSec: Word;
    begin
    Present := Now;
    DecodeDate(Present, Year, Hour, Day);
      Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
      DecodeTime()Present, Hour, Min, Sec, MSec);
    Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '+ IntToStr(Hour);
    end;

     procedure TForm1.Button1Click(Sender:   TObject); 
    var 
        Present:   TDateTime; 
        Year,   Month,   Day,   Hour,   Min,   Sec,   MSec:   Word; 
      begin 
        Present:=   Now; 
        DecodeDate(Present,   Year,   Month,   Day); 
        Label1.Caption   :=   'Today   is   Day   '   +   IntToStr(Day)   +   '   of   Month   ' 
            +   IntToStr(Month)   +   '   of   Year   '   +   IntToStr(Year); 
        DecodeTime(Present,   Hour,   Min,   Sec,   MSec); 
        Label2.Caption   :=   'The   time   is   Minute   '   +   IntToStr(Min)   +   '   of   Hour   ' 
            +   IntToStr(Hour); 
    end; 
    procedure   TForm1.Button1Click(Sender:   TObject); 
    var 
        MyDate:   TDateTime; 
    begin 
        MyDate   :=   EncodeDate(StrToInt(Edit1.Text),   StrToInt(Edit2.Text),   StrToInt(Edit3.Text)); 
        Label1.Caption   :=   DateToStr(MyDate); 
    end;

  • 相关阅读:
    jQuery on注册事件
    前端表格(Table)多条数据可以增加行删除行json封装后Post数据到后台处理
    导出Excel数据
    C#在一个实体类上新加字段并把另外一个实体类的字段值赋给它
    函数(五)-内置函数
    函数(四)-命名空间与作用域
    函数(三)-return与函数的调用
    函数(二)- 参数
    函数(一)-基本格式
    字符串格式化
  • 原文地址:https://www.cnblogs.com/zhangzhifeng/p/3573871.html
Copyright © 2011-2022 走看看