• Delphi 判断时间是否合法 -IsValidDateTime、IsValidDate、IsValidTime、IsValidDateDay


    DateUtils.IsValidDateTime
    DateUtils.IsValidDate
    DateUtils.IsValidTime
    DateUtils.IsValidDateDay
    DateUtils.IsValidDateWeek
    DateUtils.IsValidDateMonthWeek

    //可用下面几个过程抛出异常:
    DateUtils.InvalidDateDayError
    DateUtils.InvalidDateMonthWeekError
    DateUtils.InvalidDateTimeError
    DateUtils.InvalidDateWeekError
    DateUtils.InvalidDayOfWeekInMonthError

    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
      b: Boolean;
    begin
      b := IsValidDateTime(2009, 5, 21, 11, 22, 33, 999);  //True
      b := IsValidDateTime(2009, 5, 21, 11, 22, 33, 9999); //False

      b := IsValidDate(2009, 5, 21); //True
      b := IsValidDate(2009, 5, 32); //False

      b := IsValidTime(11, 22, 33, 0); //True
      b := IsValidTime(11, 22, 61, 0); //False

      b := IsValidDateDay(2009, 141); //True
      b := IsValidDateDay(2009, 366); //False

      b := IsValidDateWeek(2009, 21, 7); //True
      b := IsValidDateWeek(2009, 21, 8); //False

      b := IsValidDateMonthWeek(2009, 5, 3, 7); //True
      b := IsValidDateMonthWeek(2009, 5, 3, 8); //False

    //  ShowMessage(BoolToStr(b, True));
    end;

    end.

  • 相关阅读:
    Web后门工具WeBaCoo
    苹果内存取证工具volafox
    PlayMaker GUI的Normalized
    Arduino可穿戴教程之第一个程序——选择端口(三)
    缩略图信息提取工具vinetto
    jquery的defer
    toDo
    瀑布流案例
    js基本知识6
    js基本知识5
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/3585322.html
Copyright © 2020-2023  润新知