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

智能推荐

无名对象_class student{public:student(char* pname = "no nam-程序员宅基地

文章浏览阅读168次。代码:#include &lt;iostream&gt;#include &lt;cstring&gt; using namespace std;class Student{public:Student(char* pName="no name",int ssId=0){ strncpy(name,pName,40); name[39]='\0'; id = ssId; cout &lt;&..._class student{public:student(char* pname = "no name"){strcpy(name, p

【Android自定义View】仿Photoshop取色器ColorPicker(二)_android 仿ps吸管效果-程序员宅基地

文章浏览阅读2.3k次。ColorPicker一款仿Photoshop取色器的Android版取色器。github地址:ColorPicker前言上一篇已经简单介绍了ColorPicker的项目结构以及两种颜色空间,接下来我们详细解析一下ColorPicker的核心自定义控件ColorPickerView。ColorPickerView在阅读代码之前,我们先看一下ColorPicker的布局以及一些标注的数值在代码里的变量_android 仿ps吸管效果

计算机系统结构复习(一):Introduction概述_data-level parallelism-程序员宅基地

文章浏览阅读1.2k次,点赞2次,收藏4次。计算机系统结构复习(一):Introduction概述体系结构发展新趋势定量分析/量化研究方法计算机种类摩尔定律什么是计算机系统结构两个概念计算机系统结构与计算机组成、实现的关系体系结构发展新趋势1.新的模型:Data-level parallelism (DLP):数据级并行Thread-level parallelism (TLP):线程级并行Request-level parallelism (RLP):满足用户需求的并行2.开源架构 RISC-V3.Domain-Specific A_data-level parallelism

surface pro 4 wifi掉线问题-程序员宅基地

文章浏览阅读897次。更新你的无线网卡驱动到最新版本15.68.9032.47,重启。或者运行regedit修改注册表 HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\mrvlpcie8897,找到值 “TXAMSDU”把它从1改为0。转载于:https://www.cnblogs.com/misstaste/p/5898571.html..._surface pro 4 无线网卡

不断更新中:中文垃圾邮件过滤规则集Chinese_rules.cf_spamassassin 中文规则-程序员宅基地

文章浏览阅读4.2k次。Chinese_rules.cf的使用方法:下载Chinese_rules.cf,把该规则放在SpamAssassin存放规则的目录(一般在/usr/share/spamassassin或/usr/local/etc/mail/spamassassin)。通过wget下载的命令如下:wget -N -P /usr/share/spamassassin www.service-labs.com/dow_spamassassin 中文规则

mysql基础知识:sql通用语法,及分类(mysql学习纪念)-程序员宅基地

文章浏览阅读349次,点赞10次,收藏11次。2.SQL语句可以使用空格/缩进来增强语句的可读性。1.SQL语句可以单行或多行书写,以分号结尾。3.MySQL数据库的SQL语句不区分大小写。

随便推点

matlab快速入门(7):创建等间距向量_matla间隔相等的向量-程序员宅基地

文章浏览阅读3.8k次,点赞4次,收藏4次。(1)我们经常需要创建一些包含等间距数值的向量,例如以下向量。y = [5 6 7 8]y = 5 6 7 8任务:创建一个名为x(2)对于长向量,输入单个数值是不实际的。可用来创建等间距向量的替代便捷方法是使用:运算符并仅指定起始值和最终值。y = 5:8y = 5 6 7 8请注意,当您使用冒号运算符时,不需要方括..._matla间隔相等的向量

Git的相关操作,创建、更新、提交等,代码托管在码云上_使用git提交代码,git commit -m ' ' 提交、同步代码之后,在码云上备注是乱码。怎-程序员宅基地

文章浏览阅读5.9k次。Git的相关操作,创建、更新、提交等,代码托管在码云上一、环境配置:(1)下载安装Git Bash,具体步骤就不赘述了;(2)双击运行“Git Bash”,配置用户名及邮箱:$ git config --global user.name "xxxxxxx"$ git config --global user.email "[email protected]"_使用git提交代码,git commit -m ' ' 提交、同步代码之后,在码云上备注是乱码。怎

Java多线程之线程池深入分析(下)_线程之 1.7 doacquiresharedinterruptibly解析-程序员宅基地

文章浏览阅读1.4k次。一、数据结构与线程构造方法由于已经看到了ThreadPoolExecutor的源码,因此很容易就看到了ThreadPoolExecutor线程池的数据结构。图1描述了这种数据结构。图1 ThreadPoolExecutor 数据结构其实,即使没有上述图形描述ThreadPoolExecutor的数据结构,我们根据线程池的要求也很能够猜测出其数据结构出来。_线程之 1.7 doacquiresharedinterruptibly解析

JS快速获取图片宽高的方法_图片 src和onload 哪个快-程序员宅基地

文章浏览阅读4.8w次,点赞3次,收藏21次。快速获取图片的宽高其实是为了预先做好排版样式布局做准备,通过快速获取图片宽高的方法比onload方法要节省很多时间,甚至一分钟以上都有可能,并且这种方法适用主流浏览器包括IE低版本浏览器。我们一步一步进入这个过程。一、简陋的获取图片方式1234567891011_图片 src和onload 哪个快

严重: 在路径为/book的上下文中,Servlet[jsp]的Servlet.service()引发了具有根本原因的异常java.lang.ClassNotFoundException: org.a_严重: 在路径为/bookmanage的上下文中,servlet[jsp]的servlet.serv-程序员宅基地

文章浏览阅读6.3k次。严重: 在路径为/book的上下文中,Servlet[jsp]的Servlet.service()引发了具有根本原因的异常java.lang.ClassNotFoundException:这种报错,除了其他人的:还有一种可能:名字不一样,哪怕是空格哪怕是一个空格!..._严重: 在路径为/bookmanage的上下文中,servlet[jsp]的servlet.service()引发了具

ios砸壳_ios砸壳需要 闪退怎么砸-程序员宅基地

文章浏览阅读6.2k次。frida-ios-dump源码地址:​​​​​​GitHub - AloneMonkey/frida-ios-dump: pull decrypted ipa from jailbreak devicefrida-ios-dump是基于frida开发的一键砸壳工具,需要配置frida环境手机配置1)越狱状态2)安装openssh3)安装fridaMac配置1)安装frida,命令行:sudo pip install frida-tools (没有安装pip的话需要先安装pip)_ios砸壳需要 闪退怎么砸

推荐文章

热门文章

相关标签