delphi10.2的Date/time 实用程序单元DateUtils.pas_hourofthedaydelphi-程序员宅基地

技术标签: delphi  delphi的RTL中的comm单元文件  


这些是用于日期和时间计算的函数
{*******************************************************}
{       Date/time 实用程序单元                          }
{*******************************************************}

{ 下面的单位是符合ISO 8601标准的。
  这意味着这个单位把星期一定为星期的第一天 (5.2.3).
  另外,iso8601规定了以下 "一年中的第一个日历周包括了那一年的第一个星期四" (3.17).
  换句话说,第一个星期是第一个有四个或更多天的星期。
  有关ISO 8601的更多信息,请参阅:http://www.iso.ch/markete/8601.pdf
  最受ISO 8601影响的函数在接口部分被标记为这样。
  用“iso8601x”标记的函数不能被iso8601直接覆盖,但是它们的功能是对标准的逻辑扩展。
  本单元中的一些函数,概念或常量提供者是Jeroen W. Pluimers(http://www.all-im.com)、
   Glenn Crouch、Rune Moberg 和 Ray Lischner (http://www.tempest-sw.com).


  儒略日期和修正儒略日期函数代码基于NASA的SOHO站点
  (http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/time)

  他们将基础算法归功于Fliegel和Van Flandern(1968)
  Van Flandern在1992年,重印在天文年历的解释增刊上。


  在美国海军天文台时间服务网站(http://tycho.usno.navy.mil/mjd.html)
  上详细讨论了儒略日期和修正儒略日期
  更多信息可以在 (http://www.treasure-troves.com/astro)上找到。

  请注意,Delphi RTL日期/时间系统使用了"Proleptic 格林尼治日历"。
  也就是说,the Delphi RTL假定格林尼治日历(即公历)一直有效地回到1/1/0001。
  这个日历系统的定义可以在:
    http://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar

  因此,RTL并没有解释从儒略历到格林尼治日历的转换所导致的失去的天数。
  在16、17、18世纪,甚至更晚的时候,世界经历了不同的时期。
  (例如,俄罗斯直到1918年才采用格林尼治日历)

 更多关于这个转换,以及由此导致的缺失的日期,可以在维基百科上找到:
  http://en.wikipedia.org/wiki/Gregorian_calendar

 还应该注意的是,“儒略日期”和“儒略历”之间没有联系。


}

unit System.DateUtils;

interface
{$HPPEMIT LEGACYHPP}

uses
  System.SysUtils, System.Types, System.TimeSpan;

{ 简单的修剪函数 }

function DateOf(const AValue: TDateTime): TDateTime; inline;
function TimeOf(const AValue: TDateTime): TDateTime; inline;

{ 混杂函数 }

function IsInLeapYear(const AValue: TDateTime): Boolean;
function IsPM(const AValue: TDateTime): Boolean; inline;
function IsAM(const AValue: TDateTime): Boolean;
function IsValidDate(const AYear, AMonth, ADay: Word): Boolean;
function IsValidTime(const AHour, AMinute, ASecond, AMilliSecond: Word): Boolean;
function IsValidDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond,
  AMilliSecond: Word): Boolean; inline;
function IsValidDateDay(const AYear, ADayOfYear: Word): Boolean;
function IsValidDateWeek(const AYear, AWeekOfYear,                    {ISO 8601}
  ADayOfWeek: Word): Boolean;
function IsValidDateMonthWeek(const AYear, AMonth, AWeekOfMonth,     {ISO 8601x}
  ADayOfWeek: Word): Boolean;
function WeeksInYear(const AValue: TDateTime): Word; inline;          {ISO 8601}
function WeeksInAYear(const AYear: Word): Word;                       {ISO 8601}
function DaysInYear(const AValue: TDateTime): Word; inline;
function DaysInAYear(const AYear: Word): Word; inline;
function DaysInMonth(const AValue: TDateTime): Word;
function DaysInAMonth(const AYear, AMonth: Word): Word;
function Today: TDateTime;
function Yesterday: TDateTime;
function Tomorrow: TDateTime;
function IsToday(const AValue: TDateTime): Boolean;
function IsSameDay(const AValue, ABasis: TDateTime): Boolean;

{ Pick-a-field 函数 }

function YearOf(const AValue: TDateTime): Word;
function MonthOf(const AValue: TDateTime): Word;
function WeekOf(const AValue: TDateTime): Word;                       {ISO 8601}
function DayOf(const AValue: TDateTime): Word;
function HourOf(const AValue: TDateTime): Word;
function MinuteOf(const AValue: TDateTime): Word;
function SecondOf(const AValue: TDateTime): Word;
function MilliSecondOf(const AValue: TDateTime): Word;

{ Start/End 函数 }

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;

function StartOfTheDay(const AValue: TDateTime): TDateTime; inline;
function EndOfTheDay(const AValue: TDateTime): TDateTime;
function StartOfADay(const AYear, AMonth, ADay: Word): TDateTime; overload;
function EndOfADay(const AYear, AMonth, ADay: Word): TDateTime; overload;
function StartOfADay(const AYear, ADayOfYear: Word): TDateTime; overload;
function EndOfADay(const AYear, ADayOfYear: Word): TDateTime; overload;

{ This of that functions }

function MonthOfTheYear(const AValue: TDateTime): Word; inline;
function WeekOfTheYear(const AValue: TDateTime): Word; overload;      {ISO 8601}
function WeekOfTheYear(const AValue: TDateTime;                       {ISO 8601}
  var AYear: Word): Word; overload;
function DayOfTheYear(const AValue: TDateTime): Word;
function HourOfTheYear(const AValue: TDateTime): Word;
function MinuteOfTheYear(const AValue: TDateTime): Cardinal;
function SecondOfTheYear(const AValue: TDateTime): Cardinal;
function MilliSecondOfTheYear(const AValue: TDateTime): Int64;

function WeekOfTheMonth(const AValue: TDateTime): Word; overload;    {ISO 8601x}
function WeekOfTheMonth(const AValue: TDateTime; var AYear,          {ISO 8601x}
  AMonth: Word): Word; overload;
function DayOfTheMonth(const AValue: TDateTime): Word; inline;
function HourOfTheMonth(const AValue: TDateTime): Word;
function MinuteOfTheMonth(const AValue: TDateTime): Word;
function SecondOfTheMonth(const AValue: TDateTime): Cardinal;
function MilliSecondOfTheMonth(const AValue: TDateTime): Cardinal;

function DayOfTheWeek(const AValue: TDateTime): Word;                 {ISO 8601}
function HourOfTheWeek(const AValue: TDateTime): Word;                {ISO 8601}
function MinuteOfTheWeek(const AValue: TDateTime): Word;              {ISO 8601}
function SecondOfTheWeek(const AValue: TDateTime): Cardinal;          {ISO 8601}
function MilliSecondOfTheWeek(const AValue: TDateTime): Cardinal;     {ISO 8601}

function HourOfTheDay(const AValue: TDateTime): Word; inline;
function MinuteOfTheDay(const AValue: TDateTime): Word;
function SecondOfTheDay(const AValue: TDateTime): Cardinal;
function MilliSecondOfTheDay(const AValue: TDateTime): Cardinal;

function MinuteOfTheHour(const AValue: TDateTime): Word; inline;
function SecondOfTheHour(const AValue: TDateTime): Word;
function MilliSecondOfTheHour(const AValue: TDateTime): Cardinal;

function SecondOfTheMinute(const AValue: TDateTime): Word; inline;
function MilliSecondOfTheMinute(const AValue: TDateTime): Cardinal;

function MilliSecondOfTheSecond(const AValue: TDateTime): Word; inline;

{ 范围检查函数 }

function WithinPastYears(const ANow, AThen: TDateTime;
  const AYears: Integer): Boolean; inline;
function WithinPastMonths(const ANow, AThen: TDateTime;
  const AMonths: Integer): Boolean; inline;
function WithinPastWeeks(const ANow, AThen: TDateTime;
  const AWeeks: Integer): Boolean; inline;
function WithinPastDays(const ANow, AThen: TDateTime;
  const ADays: Integer): Boolean; inline;
function WithinPastHours(const ANow, AThen: TDateTime;
  const AHours: Int64): Boolean; inline;
function WithinPastMinutes(const ANow, AThen: TDateTime;
  const AMinutes: Int64): Boolean; inline;
function WithinPastSeconds(const ANow, AThen: TDateTime;
  const ASeconds: Int64): Boolean; inline;
function WithinPastMilliSeconds(const ANow, AThen: TDateTime;
  const AMilliSeconds: Int64): Boolean; inline;

{ 范围查询函数 }

function YearsBetween(const ANow, AThen: TDateTime): Integer;
function MonthsBetween(const ANow, AThen: TDateTime): Integer;
function WeeksBetween(const ANow, AThen: TDateTime): Integer;
function DaysBetween(const ANow, AThen: TDateTime): Integer;
function HoursBetween(const ANow, AThen: TDateTime): Int64;
function MinutesBetween(const ANow, AThen: TDateTime): Int64;
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64;

{ InRange 函数 }

function DateTimeInRange(ADateTime: TDateTime; AStartDateTime, AEndDateTime: TDateTime; aInclusive: Boolean = True): Boolean;
function DateInRange(ADate: TDate; AStartDate, AEndDate: TDate; AInclusive: Boolean = True): Boolean;
function TimeInRange(ATime: TTime; AStartTime, AEndTime: TTime; AInclusive: Boolean = True): Boolean;


{ 范围涵盖函数 }
{ YearSpan和MonthSpan 接近,不是很精确,但是非常接近 }
function YearSpan(const ANow, AThen: TDateTime): Double;
function MonthSpan(const ANow, AThen: TDateTime): Double;
function WeekSpan(const ANow, AThen: TDateTime): Double;
function DaySpan(const ANow, AThen: TDateTime): Double;
function HourSpan(const ANow, AThen: TDateTime): Double;
function MinuteSpan(const ANow, AThen: TDateTime): Double;
function SecondSpan(const ANow, AThen: TDateTime): Double;
function MilliSecondSpan(const ANow, AThen: TDateTime): Double;

{ 递增/递减datetime字段 }

function IncYear(const AValue: TDateTime;
  const ANumberOfYears: Integer = 1): TDateTime; inline;
// IncMonth函数在SysUtils中
function IncWeek(const AValue: TDateTime;
  const ANumberOfWeeks: Integer = 1): TDateTime; inline;
function IncDay(const AValue: TDateTime;
  const ANumberOfDays: Integer = 1): TDateTime; inline;
function IncHour(const AValue: TDateTime;
  const ANumberOfHours: Int64 = 1): TDateTime; inline;
function IncMinute(const AValue: TDateTime;
  const ANumberOfMinutes: Int64 = 1): TDateTime; inline;
function IncSecond(const AValue: TDateTime;
  const ANumberOfSeconds: Int64 = 1): TDateTime; inline;
function IncMilliSecond(const AValue: TDateTime;
  const ANumberOfMilliSeconds: Int64 = 1): TDateTime;

{ 统一的编码/解码函数,可以同时处理所有的datetime字段 }

function EncodeDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond,
  AMilliSecond: Word): TDateTime;
procedure DecodeDateTime(const AValue: TDateTime; out AYear, AMonth, ADay,
  AHour, AMinute, ASecond, AMilliSecond: Word);

{ 编码/解码函数,每年的工作周数和每周的工作天数 }

function EncodeDateWeek(const AYear, AWeekOfYear: Word;               {ISO 8601}
  const ADayOfWeek: Word = 1): TDateTime;
procedure DecodeDateWeek(const AValue: TDateTime; out AYear,          {ISO 8601}
  AWeekOfYear, ADayOfWeek: Word);

{ 编码/解码函数,每年的工作天数 }

function EncodeDateDay(const AYear, ADayOfYear: Word): TDateTime;
procedure DecodeDateDay(const AValue: TDateTime; out AYear, ADayOfYear: Word);

{ 编码/解码函数,每月的工作周数 }

function EncodeDateMonthWeek(const AYear, AMonth, AWeekOfMonth,      {ISO 8601x}
  ADayOfWeek: Word): TDateTime;
procedure DecodeDateMonthWeek(const AValue: TDateTime;               {ISO 8601x}
  out AYear, AMonth, AWeekOfMonth, ADayOfWeek: Word);

{ 下面的函数与上面的函数相似,
  只不过它不会在失败时产生异常,而是返回false}

function TryEncodeDateTime(const AYear, AMonth, ADay, AHour, AMinute, ASecond,
  AMilliSecond: Word; out AValue: TDateTime): Boolean;
function TryEncodeDateWeek(const AYear, AWeekOfYear: Word;            {ISO 8601}
  out AValue: TDateTime; const ADayOfWeek: Word = 1): Boolean;
function TryEncodeDateDay(const AYear, ADayOfYear: Word;
  out AValue: TDateTime): Boolean;
function TryEncodeDateMonthWeek(const AYear, AMonth, AWeekOfMonth,   {ISO 8601x}
  ADayOfWeek: Word; var AValue: TDateTime): Boolean;

{用于datetime字段的Recode函数 }

function RecodeYear(const AValue: TDateTime; const AYear: Word): TDateTime;
function RecodeMonth(const AValue: TDateTime; const AMonth: Word): TDateTime;
function RecodeDay(const AValue: TDateTime; const ADay: Word): TDateTime;
function RecodeHour(const AValue: TDateTime; const AHour: Word): TDateTime;
function RecodeMinute(const AValue: TDateTime; const AMinute: Word): TDateTime;
function RecodeSecond(const AValue: TDateTime; const ASecond: Word): TDateTime;
function RecodeMilliSecond(const AValue: TDateTime;
  const AMilliSecond: Word): TDateTime;

function RecodeDate(const AValue: TDateTime; const AYear, AMonth,
  ADay: Word): TDateTime;
function RecodeTime(const AValue: TDateTime; const AHour, AMinute, ASecond,
  AMilliSecond: Word): TDateTime;
function RecodeDateTime(const AValue: TDateTime; const AYear, AMonth, ADay,
  AHour, AMinute, ASecond, AMilliSecond: Word): TDateTime;

{ 下面的函数与上面的函数类似,只不过它不会在失败时产生异常,而是返回false
  }

function TryRecodeDateTime(const AValue: TDateTime; const AYear, AMonth, ADay,
  AHour, AMinute, ASecond, AMilliSecond: Word; out AResult: TDateTime): Boolean;

{ Fuzzy comparison }

function CompareDateTime(const A, B: TDateTime): TValueRelationship;
function SameDateTime(const A, B: TDateTime): Boolean;
function CompareDate(const A, B: TDateTime): TValueRelationship;
function SameDate(const A, B: TDateTime): Boolean;
function CompareTime(const A, B: TDateTime): TValueRelationship;
function SameTime(const A, B: TDateTime): Boolean;

{ 对于给定的日期,这些函数会告诉你一个月(或一年)的周的哪一天。
  如果是周四,,他们会告诉你这个月(或年)的第一个,第二个,星期四。
  记住,即使是今年的第一个星期四,也不意味着它是一年中第一周。
  有关更多信息,请参阅上面的ISO 8601。 }

function NthDayOfWeek(const AValue: TDateTime): Word;

procedure DecodeDayOfWeekInMonth(const AValue: TDateTime; out AYear, AMonth,
  ANthDayOfWeek, ADayOfWeek: Word);

function EncodeDayOfWeekInMonth(const AYear, AMonth, ANthDayOfWeek,
  ADayOfWeek: Word): TDateTime;
function TryEncodeDayOfWeekInMonth(const AYear, AMonth, ANthDayOfWeek,
  ADayOfWeek: Word; out AValue: TDateTime): Boolean;

{ 错误报告 }

procedure InvalidDateTimeError(const AYear, AMonth, ADay, AHour, AMinute,
  ASecond, AMilliSecond: Word; const ABaseDate: TDateTime = 0);
procedure InvalidDateWeekError(const AYear, AWeekOfYear, ADayOfWeek: Word);
procedure InvalidDateDayError(const AYear, ADayOfYear: Word);
procedure InvalidDateMonthWeekError(const AYear, AMonth, AWeekOfMonth,
  ADayOfWeek: Word);
procedure InvalidDayOfWeekInMonthError(const AYear, AMonth, ANthDayOfWeek,
  ADayOfWeek: Word);

{ 儒略历和修正儒略历 日期转换支持 }
{ 请注意,并非所有的儒略历(或修正儒略历)都可编码为TDateTime }

function DateTimeToJulianDate(const AValue: TDateTime): Double;
function JulianDateToDateTime(const AValue: Double): TDateTime;
function TryJulianDateToDateTime(const AValue: Double;
  out ADateTime: TDateTime): Boolean;

function DateTimeToModifiedJulianDate(const AValue: TDateTime): Double;
function ModifiedJulianDateToDateTime(const AValue: Double): TDateTime;
function TryModifiedJulianDateToDateTime(const AValue: Double;
  out ADateTime: TDateTime): Boolean;

{ Unix日期转换支持 }

function DateTimeToUnix(const AValue: TDateTime; AInputIsUTC: Boolean = True): Int64;
function UnixToDateTime(const AValue: Int64; AReturnUTC: Boolean = True): TDateTime;

{ 本单元使用的常量 }

const
  DaysPerWeek = 7;
  WeeksPerFortnight = 2;
  MonthsPerYear = 12;
  YearsPerDecade = 10;
  YearsPerCentury = 100;
  YearsPerMillennium = 1000;

  DayMonday = 1;
  DayTuesday = 2;
  DayWednesday = 3;
  DayThursday = 4;
  DayFriday = 5;
  DaySaturday = 6;
  DaySunday = 7;

  MonthJanuary = 1;
  MonthFebruary = 2;
  MonthMarch = 3;
  MonthApril = 4;
  MonthMay = 5;
  MonthJune = 6;
  MonthJuly = 7;
  MonthAugust = 8;
  MonthSeptember = 9;
  MonthOctober = 10;
  MonthNovember = 11;
  MonthDecember = 12;


  OneHour = 1 / HoursPerDay;
  {$HPPEMIT OPENNAMESPACE}
  {$EXTERNALSYM OneHour}
  {$HPPEMIT 'extern const System::Extended OneHour /*= 4.166667E-02*/;'}
  OneMinute = 1 / MinsPerDay;
  {$EXTERNALSYM OneMinute}
  {$HPPEMIT 'extern const System::Extended OneMinute /*= 6.944444E-04*/;'}
  OneSecond = 1 / SecsPerDay;
  {$EXTERNALSYM OneSecond}
  {$HPPEMIT 'extern const System::Extended OneSecond /*= 1.157407E-05*/;'}
  OneMillisecond = 1 / MSecsPerDay;
  {$EXTERNALSYM OneMillisecond}
  {$HPPEMIT 'extern const System::Extended OneMillisecond /*= 1.157407E-08*/;'}

  EpochAsJulianDate = 2415018.5;
  {$EXTERNALSYM EpochAsJulianDate}
  {$HPPEMIT 'extern const System::Extended EpochAsJulianDate /*= 2.415018E+06*/;'}
  {$HPPEMIT CLOSENAMESPACE}
  EpochAsUnixDate   = -2209161600;

  { 这是每年的实际天数,但你需要知道这是否是闰年}
  DaysPerYear: array [Boolean] of Word = (365, 366);

  { 用于您不想管理的datetime字段的RecodeDate、recode和RecodeDateTime }
  {   }
  RecodeLeaveFieldAsIs = High(Word);

{ 本单元使用的全局变量 }

var
  { 平均4年跨度 }
  ApproxDaysPerMonth: Double = 30.4375;
  ApproxDaysPerYear: Double  = 365.25;

  { 以上是一个正常的4年平均的每个月/年的平均天数。 }
  { 我们使用这些近似值,因为它们在接下来的一个世纪里更准确。 }
  {  在那之后你可能想要转换到这400年的近似值... }
  {   }
  {    ApproxDaysPerMonth = 30.436875 }
  {    ApproxDaysPerYear  = 365.2425 }

type
  { 本单元中使用的异常类型,用于指示给定的本地时间位于无效周期内。
    (通常是在DST的时间转换过程中丢失的小时). }
  ELocalTimeInvalid = class(Exception);
  EDateTimeException = class(Exception);

  { 指定日期/时间值的类型 }
  TLocalTimeType = (
    { 当DST规则无效时,识别一个日期/时间值 }
    lttStandard,
    { 当DST规则生效时,识别一个日期/时间值 }
    lttDaylight,
    { 识别位于模糊区间的日期/时间值 (例子, 重复的小时) }
    lttAmbiguous,
    { 识别位于无效区间中的日期/时间值 (漏掉的小时) }
    lttInvalid
  );

  { 使用TTimeZone来访问一组方法, 这些方法可用于在本地时间
    (就像现在的时区用户所看到的那样)和通用时间之间进行转换。 }
  TTimeZone = class abstract
  private
    {包含“本地”时区。 :在单元initialization部分实例化 }
    class var FLocal: TTimeZone;

    { 在initialization期间调用。 初始化缓存(空)和本地时区 }
    class constructor Create;

    { 在initialization期间调用。 销毁内部缓存和包含的时区 (包括本地的那个) }
    class destructor Destroy;

    { 返回当前时区的缩写名称 }
    function GetAbbreviationForNow: string; inline;

    { 返回当前时区的显示名称 }
    function GetDisplayNameForNow: string; inline;

    { 为给定的本地时间计算UTC偏移量。UTC偏移量表示时间的长度,
      这应该从给定的本地时间中减去,以获得国际标准时间。 }
    function GetUtcOffsetInSeconds(const ADateTime: TDateTime; const ForceDaylight: Boolean): Int64;

    { 返回当前时区的UTC偏移量 }
    function GetCurrentUtcOffset: TTimeSpan; inline;
  protected
    { 在派生类中覆盖,以提供关于本地时间的偏移信息。}
    procedure DoGetOffsetsAndType(
      const ADateTime: TDateTime; out AOffset, ADstSave: Int64; out AType: TLocalTimeType); virtual; abstract;

    { 在派生类中重写,以在给定的本地时间提供一个TZ名称。 }
    function DoGetDisplayName(const ADateTime: TDateTime; const ForceDaylight: Boolean): string; virtual; abstract;

    { 重载返回时区ID。}
    function DoGetID: string; virtual; abstract;
  public
    { 为给定的本地时间计算UTC偏移量。UTC偏移量表示时间的长度,
      这应该从给定的本地时间中减去,以获得国际标准时间。
     ForceDaylight指定了模糊时间的处理方式。}
    function GetUtcOffset(const ADateTime: TDateTime; const ForceDaylight: Boolean = False): TTimeSpan; inline;

    { 将给定的本地时间转换为国际标准时间。
      ForceDaylight指定了模糊时间的处理方式。 }
    function ToUniversalTime(const ADateTime: TDateTime; const ForceDaylight: Boolean = False): TDateTime; inline;

    { 将一个给定的国际标准时间转换为本地时间。 }
    function ToLocalTime(const ADateTime: TDateTime): TDateTime;

    { 根据给定的日期/时间,返回时区的全名(如果可能的话是本地化的) }
    function GetDisplayName(const ADateTime: TDateTime; const ForceDaylight: Boolean = False): string;

    { 返回一个简短的名称,可以用来定位与UTC时间相关的本地时间。
      非本地化的,总是指定的,并且有形式: GMT[+|-HH[:MM]]. }
    function GetAbbreviation(const ADateTime: TDateTime; const ForceDaylight: Boolean = False): string;

    { 在这个时区返回给定日期/时间的类型。 }
    function GetLocalTimeType(const ADateTime: TDateTime): TLocalTimeType; inline;

    {检查给定的本地日期/时间是否位于DST周期之外。
     ForceDaylight指定了时间的处理方式。 }
    function IsStandardTime(const ADateTime: TDateTime; const ForceDaylight: Boolean = False): Boolean;

    { 检查给定的本地日期/时间是否无效(位于不确定的小时(s)内) }
    function IsInvalidTime(const ADateTime: TDateTime): Boolean; inline;

    { 检查给定的本地日期/时间是否为模糊(位于重复的小时(s)中) }
    function IsAmbiguousTime(const ADateTime: TDateTime): Boolean; inline;

    { 检查给定的本地日期/时间是否位于DST周期内。
      ForceDaylight指定了时间的处理方式。}
    function IsDaylightTime(const ADateTime: TDateTime; const ForceDaylight: Boolean = False): Boolean;

    { 返回时区标识字符串。 }
    property ID: string read DoGetID;

    { 指定这个时区的显示名称(如果可能的话本地化)。 }
    property DisplayName: string read GetDisplayNameForNow;

    { 当前时区的缩写。非本地化的,总是指定的,并且有表单:GMT[+|-HH[:MM]]。}
    property Abbreviation: string read GetAbbreviationForNow;

    { 指定时区当前的UTC偏移量。 }
    property UtcOffset: TTimeSpan read GetCurrentUtcOffset;

    { 指定本地时区。
      使用此属性获得一个TTimeZone实例,该实例标识当前用户的时区。 }
    class property Local: TTimeZone read FLocal;
  end;

/// <summary>
/// 将一个ISO8601编码的日期/时间字符串转换为TDateTime。如果AReturnUTC 是 false,结果是在当地时间。
/// </summary>
/// <example>
/// <para> "2013-10-18T20:36:22.966Z"  </para>
/// <para> 这是UTC时间20:36(祖鲁)。如果本地时区是MEST(UTC+2),那么产生的时间将是22:36。</para>
/// </example>
function ISO8601ToDate(const AISODate: string; AReturnUTC: Boolean = True): TDateTime;

/// <summary> 尝试将ISO8601编码的日期/时间字符串转换为TDateTime。 </summary>
/// <param name ="AISODate"> 一个ISO8601字符串, 举例来说, "2013-10-18T20:36:22.966Z" </param>
/// <param name ="Value">  输出TDateTime值的参数 </param>
/// <param name = "AReturnUTC">  UTC时间(祖鲁语) </param>
/// <returns> 布尔表明成功 </returns>
function TryISO8601ToDate(const AISODate: string; out Value: TDateTime; AReturnUTC: Boolean = True): Boolean;

/// <summary> 将TDateTime值转换为ISO8601格式。 </summary>
/// <param name="ADate"> 一个TDateTime值 </param>
/// <param name="AInputIsUTC">
/// 如果AInputIsUTC =true, 然后得到的ISO8601字符串将显示与ADate相同的时间。</param>
/// <returns> ADate的ISO8601表示。得到的ISO字符串将在UTC时间,也就是说,将有一个Z(祖鲁)的后缀
/// 如果AInputIsUTC = true, 那么,ADate的时间部分将不会被修改。 </returns>
function DateToISO8601(const ADate: TDateTime; AInputIsUTC: Boolean = True): string;

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/vbfgm/article/details/79840740

智能推荐

稀疏编码的数学基础与理论分析-程序员宅基地

文章浏览阅读290次,点赞8次,收藏10次。1.背景介绍稀疏编码是一种用于处理稀疏数据的编码技术,其主要应用于信息传输、存储和处理等领域。稀疏数据是指数据中大部分元素为零或近似于零的数据,例如文本、图像、音频、视频等。稀疏编码的核心思想是将稀疏数据表示为非零元素和它们对应的位置信息,从而减少存储空间和计算复杂度。稀疏编码的研究起源于1990年代,随着大数据时代的到来,稀疏编码技术的应用范围和影响力不断扩大。目前,稀疏编码已经成为计算...

EasyGBS国标流媒体服务器GB28181国标方案安装使用文档-程序员宅基地

文章浏览阅读217次。EasyGBS - GB28181 国标方案安装使用文档下载安装包下载,正式使用需商业授权, 功能一致在线演示在线API架构图EasySIPCMSSIP 中心信令服务, 单节点, 自带一个 Redis Server, 随 EasySIPCMS 自启动, 不需要手动运行EasySIPSMSSIP 流媒体服务, 根..._easygbs-windows-2.6.0-23042316使用文档

【Web】记录巅峰极客2023 BabyURL题目复现——Jackson原生链_原生jackson 反序列化链子-程序员宅基地

文章浏览阅读1.2k次,点赞27次,收藏7次。2023巅峰极客 BabyURL之前AliyunCTF Bypassit I这题考查了这样一条链子:其实就是Jackson的原生反序列化利用今天复现的这题也是大同小异,一起来整一下。_原生jackson 反序列化链子

一文搞懂SpringCloud,详解干货,做好笔记_spring cloud-程序员宅基地

文章浏览阅读734次,点赞9次,收藏7次。微服务架构简单的说就是将单体应用进一步拆分,拆分成更小的服务,每个服务都是一个可以独立运行的项目。这么多小服务,如何管理他们?(服务治理 注册中心[服务注册 发现 剔除])这么多小服务,他们之间如何通讯?这么多小服务,客户端怎么访问他们?(网关)这么多小服务,一旦出现问题了,应该如何自处理?(容错)这么多小服务,一旦出现问题了,应该如何排错?(链路追踪)对于上面的问题,是任何一个微服务设计者都不能绕过去的,因此大部分的微服务产品都针对每一个问题提供了相应的组件来解决它们。_spring cloud

Js实现图片点击切换与轮播-程序员宅基地

文章浏览阅读5.9k次,点赞6次,收藏20次。Js实现图片点击切换与轮播图片点击切换<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <script type="text/ja..._点击图片进行轮播图切换

tensorflow-gpu版本安装教程(过程详细)_tensorflow gpu版本安装-程序员宅基地

文章浏览阅读10w+次,点赞245次,收藏1.5k次。在开始安装前,如果你的电脑装过tensorflow,请先把他们卸载干净,包括依赖的包(tensorflow-estimator、tensorboard、tensorflow、keras-applications、keras-preprocessing),不然后续安装了tensorflow-gpu可能会出现找不到cuda的问题。cuda、cudnn。..._tensorflow gpu版本安装

随便推点

物联网时代 权限滥用漏洞的攻击及防御-程序员宅基地

文章浏览阅读243次。0x00 简介权限滥用漏洞一般归类于逻辑问题,是指服务端功能开放过多或权限限制不严格,导致攻击者可以通过直接或间接调用的方式达到攻击效果。随着物联网时代的到来,这种漏洞已经屡见不鲜,各种漏洞组合利用也是千奇百怪、五花八门,这里总结漏洞是为了更好地应对和预防,如有不妥之处还请业内人士多多指教。0x01 背景2014年4月,在比特币飞涨的时代某网站曾经..._使用物联网漏洞的使用者

Visual Odometry and Depth Calculation--Epipolar Geometry--Direct Method--PnP_normalized plane coordinates-程序员宅基地

文章浏览阅读786次。A. Epipolar geometry and triangulationThe epipolar geometry mainly adopts the feature point method, such as SIFT, SURF and ORB, etc. to obtain the feature points corresponding to two frames of images. As shown in Figure 1, let the first image be ​ and th_normalized plane coordinates

开放信息抽取(OIE)系统(三)-- 第二代开放信息抽取系统(人工规则, rule-based, 先抽取关系)_语义角色增强的关系抽取-程序员宅基地

文章浏览阅读708次,点赞2次,收藏3次。开放信息抽取(OIE)系统(三)-- 第二代开放信息抽取系统(人工规则, rule-based, 先关系再实体)一.第二代开放信息抽取系统背景​ 第一代开放信息抽取系统(Open Information Extraction, OIE, learning-based, 自学习, 先抽取实体)通常抽取大量冗余信息,为了消除这些冗余信息,诞生了第二代开放信息抽取系统。二.第二代开放信息抽取系统历史第二代开放信息抽取系统着眼于解决第一代系统的三大问题: 大量非信息性提取(即省略关键信息的提取)、_语义角色增强的关系抽取

10个顶尖响应式HTML5网页_html欢迎页面-程序员宅基地

文章浏览阅读1.1w次,点赞6次,收藏51次。快速完成网页设计,10个顶尖响应式HTML5网页模板助你一臂之力为了寻找一个优质的网页模板,网页设计师和开发者往往可能会花上大半天的时间。不过幸运的是,现在的网页设计师和开发人员已经开始共享HTML5,Bootstrap和CSS3中的免费网页模板资源。鉴于网站模板的灵活性和强大的功能,现在广大设计师和开发者对html5网站的实际需求日益增长。为了造福大众,Mockplus的小伙伴整理了2018年最..._html欢迎页面

计算机二级 考试科目,2018全国计算机等级考试调整,一、二级都增加了考试科目...-程序员宅基地

文章浏览阅读282次。原标题:2018全国计算机等级考试调整,一、二级都增加了考试科目全国计算机等级考试将于9月15-17日举行。在备考的最后冲刺阶段,小编为大家整理了今年新公布的全国计算机等级考试调整方案,希望对备考的小伙伴有所帮助,快随小编往下看吧!从2018年3月开始,全国计算机等级考试实施2018版考试大纲,并按新体系开考各个考试级别。具体调整内容如下:一、考试级别及科目1.一级新增“网络安全素质教育”科目(代..._计算机二级增报科目什么意思

conan简单使用_apt install conan-程序员宅基地

文章浏览阅读240次。conan简单使用。_apt install conan