zoukankan      html  css  js  c++  java
  • delphi日期的使用

    delphi中日期的函数大部分都在DateUtil中。

    1、获取当年当月当周的第一天和最后一天 函数

    uses DateUtils;

    function StartOfTheYear(const AValue: TDateTime): TDateTime;  //获取当年的第一天
    function EndOfTheYear(const AValue: TDateTime): TDateTime;
    function StartOfAYear(const AYear: Word): TDateTime;
    function EndOfAYear(const AYear: Word): TDateTime;

    function StartOfTheMonth(const AValue: TDateTime): TDateTime;
    function EndOfTheMonth(const AValue: TDateTime): TDateTime;
    function StartOfAMonth(const AYear, AMonth: Word): TDateTime;
    function EndOfAMonth(const AYear, AMonth: Word): TDateTime;

    function StartOfTheWeek(const AValue: TDateTime): TDateTime;           {ISO 8601}
    function EndOfTheWeek(const AValue: TDateTime): TDateTime;             {ISO 8601}
    function StartOfAWeek(const AYear, AWeekOfYear: Word;                  {ISO 8601}
       const ADayOfWeek: Word = 1): TDateTime;
    function EndOfAWeek(const AYear, AWeekOfYear: Word;                    {ISO 8601}
       const ADayOfWeek: Word = 7): TDateTime;

    2、Example

    获取年月日期
    procedure TForm1.FormCreate(Sender: TObject);
    var
    dt: TDateTime;
    d: TDate;
    t: TTime;
    y: Word;
    begin
    dt := Now;
    d := Date;
    t := Time;
    y := CurrentYear;

    ShowMessage(DateTimeToStr(dt)); //2009-5-21 17:45:50
    ShowMessage(DateToStr(d)); //2009-5-21
    ShowMessage(TimeToStr(t)); //17:45:50
    ShowMessage(IntToStr(y)); //2009
    end;

  • 相关阅读:
    JSONP原理
    什么是跨域,如何解决
    工程化与模块化开
    vue双向数据绑定原理
    vuex原理
    BFC 原理
    http状态码 301、302区别
    用户页面打开很慢,有哪些优化方式?
    webpack打包
    Promise 原理
  • 原文地址:https://www.cnblogs.com/rongxiaoya/p/2882011.html
Copyright © 2011-2022 走看看