From 95638fda73d34e1e60ce0212a21b6a6631fa1431 Mon Sep 17 00:00:00 2001 From: Cleber Moies Grings Date: Wed, 25 Sep 2024 06:41:28 +0200 Subject: [PATCH 1/4] Update project test --- Tests/TDateTimeHelperTests.dpr | 61 ++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/Tests/TDateTimeHelperTests.dpr b/Tests/TDateTimeHelperTests.dpr index d55e64f..72dc4bf 100755 --- a/Tests/TDateTimeHelperTests.dpr +++ b/Tests/TDateTimeHelperTests.dpr @@ -1,48 +1,63 @@ program TDateTimeHelperTests; {$IFNDEF TESTINSIGHT} -{$APPTYPE CONSOLE} -{$ENDIF}{$STRONGLINKTYPES ON} + {$APPTYPE CONSOLE} +{$ENDIF} +{$STRONGLINKTYPES ON} uses + {$IFDEF EurekaLog} + EMemLeaks, + EResLeaks, + EDebugJCL, + EDebugExports, + EFixSafeCallException, + EMapWin32, + EAppVCL, + EDialogWinAPIEurekaLogDetailed, + EDialogWinAPIStepsToReproduce, + ExceptionLog7, + {$ENDIF EurekaLog} System.SysUtils, +{$IFDEF TESTINSIGHT} + TestInsight.DUnitX, +{$ELSE} DUnitX.Loggers.Console, DUnitX.Loggers.Xml.NUnit, - DUnitX.TestFramework, -{$IFDEF VER240} - DUnitX.Init, // Workaround for Delphi XE3 Compiler Bug -{$ENDIF} +{$ENDIF } DateTimeHelper in '..\DateTimeHelper.pas', TDateTimeHelper.Tests in 'TDateTimeHelper.Tests.pas'; +{$IFNDEF TESTINSIGHT} var - Runner: ITestRunner; - Results: IRunResults; - Logger: ITestLogger; - NUnitLogger: ITestLogger; + runner: ITestRunner; + results: IRunResults; + logger: ITestLogger; + nunitLogger : ITestLogger; +{$ENDIF} begin + ReportMemoryLeaksOnShutdown := True; {$IFDEF TESTINSIGHT} TestInsight.DUnitX.RunRegisteredTests; - Exit; -{$ENDIF} +{$ELSE} try //Check command line options, will exit if invalid TDUnitX.CheckCommandLine; //Create the test runner - Runner := TDUnitX.CreateRunner; + LRunner := TDUnitX.CreateRunner; //Tell the runner to use RTTI to find Fixtures - Runner.UseRTTI := True; + LRunner.UseRTTI := True; //tell the runner how we will log things //Log to the console window - Logger := TDUnitXConsoleLogger.Create(True); - Runner.AddLogger(Logger); + LLogger := TDUnitXConsoleLogger.Create(true); + LRunner.AddLogger(LLogger); //Generate an NUnit compatible XML File - NUnitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile); - Runner.AddLogger(NUnitLogger); - Runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests; + LNUnitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile); + LRunner.AddLogger(LNUnitLogger); + LRunner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests; //Run tests - Results := Runner.Execute; - if not Results.AllPassed then + LResults := LRunner.Execute; + if not LResults.AllPassed then System.ExitCode := EXIT_ERRORS; {$IFNDEF CI} @@ -57,4 +72,8 @@ begin on E: Exception do System.Writeln(E.ClassName, ': ', E.Message); end; +{$ENDIF} + end. + + From 5abe7c8a6f55644197c5f1aac4a6609ebd42dab6 Mon Sep 17 00:00:00 2001 From: Cleber Moies Grings Date: Wed, 25 Sep 2024 06:46:50 +0200 Subject: [PATCH 2/4] Format --- DateTimeHelper.pas | 374 +++++++++++++++++++++------------------------ 1 file changed, 177 insertions(+), 197 deletions(-) diff --git a/DateTimeHelper.pas b/DateTimeHelper.pas index d897b6d..7d91023 100755 --- a/DateTimeHelper.pas +++ b/DateTimeHelper.pas @@ -32,117 +32,206 @@ interface uses - System.SysUtils, System.Types, System.DateUtils; + System.SysUtils, + System.Types, + System.DateUtils; type TDateTimeHelper = record helper for TDateTime private - function GetDay: Word; inline; + /// Parse a string as TDateTime, using a string format ex.('MM/dd/yyyy hh:mm:ss') + /// TDateTime + /// (string) + /// (string) + /// (Char) + /// (Char) + class function Parse(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; static; inline; + /// Parse a string as TDateTime, using local string ex. ('en-US') + /// TDateTime + /// (string) + /// (string) + class function ParseLocal(Date: string; local: string = ''): TDateTime; static; inline; function GetDate: TDateTime; inline; + function GetDay: Word; inline; function GetDayOfWeek: Word; inline; function GetDayOfYear: Word; inline; function GetHour: Word; inline; function GetMillisecond: Word; inline; function GetMinute: Word; inline; function GetMonth: Word; inline; + class function GetNow: TDateTime; static; inline; function GetSecond: Word; inline; function GetTime: TDateTime; inline; - function GetYear: Word; inline; - class function GetNow: TDateTime; static; inline; class function GetToday: TDateTime; static; inline; class function GetTomorrow: TDateTime; static; inline; - class function GetYesterDay: TDateTime; static; inline; - function GetUnixTime: Int64; function GetTotalSecounds: Int64; - // Parse a string as TDateTime, using a string format ex.('MM/dd/yyyy hh:mm:ss') - class function Parse(Date: string; aFormat: string = ''; aDateSeparator: - Char = #0; aTimeSeparator: Char = #0): TDateTime; static; inline; - - // Parse a string as TDateTime, using local string ex. ('en-US') - class function ParseLocal(Date: string; local: string = ''): TDateTime; - static; inline; + function GetUnixTime: Int64; + function GetYear: Word; inline; + class function GetYesterDay: TDateTime; static; inline; public - class function Create(const aYear, aMonth, aDay: Word): TDateTime; overload; - static; inline; - class function Create(const aYear, aMonth, aDay, aHour, aMinute, aSecond, - aMillisecond: Word): TDateTime; overload; static; inline; - class function Create(Date: string; aFormat: string = ''; aDateSeparator: - Char = #0; aTimeSeparator: Char = #0): TDateTime; overload; static; inline; - class function CreateLocal(Date: string; local: string = ''): TDateTime; - static; inline; - class function CreateUnixTime(const Value: Int64): TDateTime; static; inline; + class function Create(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; overload; static; inline; + class function Create(const aYear, aMonth, aDay: Word): TDateTime; overload; static; inline; + class function Create(const aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond: Word): TDateTime; overload; static; inline; + class function CreateLocal(Date: string; local: string = ''): TDateTime; static; inline; class function CreateTotalSeconds(const Value: Int64): TDateTime; static; inline; - class property Now: TDateTime read GetNow; - class property Today: TDateTime read GetToday; - class property Yesterday: TDateTime read GetYesterDay; - class property Tomorrow: TDateTime read GetTomorrow; - property Date: TDateTime read GetDate; - property Time: TDateTime read GetTime; - property DayOfWeek: Word read GetDayOfWeek; - property DayOfYear: Word read GetDayOfYear; - property Year: Word read GetYear; - property Month: Word read GetMonth; - property Day: Word read GetDay; - property Hour: Word read GetHour; - property Minute: Word read GetMinute; - property Second: Word read GetSecond; - property Millisecond: Word read GetMillisecond; - property UnixTime: Int64 read GetUnixTime; - property TotalSeconds: Int64 read GetTotalSecounds; - function ToString(const aFormatStr: string = ''): string; inline; - function StartOfYear: TDateTime; inline; - function EndOfYear: TDateTime; inline; - function StartOfMonth: TDateTime; inline; - function EndOfMonth: TDateTime; inline; - function StartOfWeek: TDateTime; inline; - function EndOfWeek: TDateTime; inline; - function StartOfDay: TDateTime; inline; - function EndOfDay: TDateTime; inline; - function AddYears(const aNumberOfYears: Integer = 1): TDateTime; inline; - function AddMonths(const aNumberOfMonths: Integer = 1): TDateTime; inline; + class function CreateUnixTime(const Value: Int64): TDateTime; static; inline; function AddDays(const aNumberOfDays: Integer = 1): TDateTime; inline; function AddHours(const aNumberOfHours: Int64 = 1): TDateTime; inline; + function AddMilliseconds(const aNumberOfMilliseconds: Int64 = 1): TDateTime; inline; function AddMinutes(const aNumberOfMinutes: Int64 = 1): TDateTime; inline; + function AddMonths(const aNumberOfMonths: Integer = 1): TDateTime; inline; function AddSeconds(const aNumberOfSeconds: Int64 = 1): TDateTime; inline; - function AddMilliseconds(const aNumberOfMilliseconds: Int64 = 1): TDateTime; inline; + function AddYears(const aNumberOfYears: Integer = 1): TDateTime; inline; function CompareTo(const aDateTime: TDateTime): TValueRelationship; inline; + function DaysBetween(const aDateTime: TDateTime): Integer; inline; + function EndOfDay: TDateTime; inline; + function EndOfMonth: TDateTime; inline; + function EndOfWeek: TDateTime; inline; + function EndOfYear: TDateTime; inline; function Equals(const aDateTime: TDateTime): Boolean; inline; - function IsSameDay(const aDateTime: TDateTime): Boolean; inline; - function InRange(const aStartDateTime, aEndDateTime: TDateTime; const - aInclusive: Boolean = True): Boolean; inline; - function IsInLeapYear: Boolean; inline; - function IsToday: Boolean; inline; + function HoursBetween(const aDateTime: TDateTime): Int64; inline; + function InRange(const aStartDateTime, aEndDateTime: TDateTime; const aInclusive: Boolean = True): Boolean; inline; function IsAM: Boolean; inline; + function IsInLeapYear: Boolean; inline; function IsPM: Boolean; inline; - function YearsBetween(const aDateTime: TDateTime): Integer; inline; - function MonthsBetween(const aDateTime: TDateTime): Integer; inline; - function WeeksBetween(const aDateTime: TDateTime): Integer; inline; - function DaysBetween(const aDateTime: TDateTime): Integer; inline; - function HoursBetween(const aDateTime: TDateTime): Int64; inline; + function IsSameDay(const aDateTime: TDateTime): Boolean; inline; + function IsToday: Boolean; inline; + function MilliSecondsBetween(const aDateTime: TDateTime): Int64; inline; function MinutesBetween(const aDateTime: TDateTime): Int64; inline; + function MonthsBetween(const aDateTime: TDateTime): Integer; inline; function SecondsBetween(const aDateTime: TDateTime): Int64; inline; - function MilliSecondsBetween(const aDateTime: TDateTime): Int64; inline; - function WithinYears(const aDateTime: TDateTime; const aYears: Integer): - Boolean; inline; - function WithinMonths(const aDateTime: TDateTime; const aMonths: Integer): - Boolean; inline; - function WithinWeeks(const aDateTime: TDateTime; const aWeeks: Integer): - Boolean; inline; - function WithinDays(const aDateTime: TDateTime; const aDays: Integer): - Boolean; inline; - function WithinHours(const aDateTime: TDateTime; const aHours: Int64): - Boolean; inline; - function WithinMinutes(const aDateTime: TDateTime; const aMinutes: Int64): - Boolean; inline; - function WithinSeconds(const aDateTime: TDateTime; const aSeconds: Int64): - Boolean; inline; - function WithinMilliseconds(const aDateTime: TDateTime; const AMilliseconds: - Int64): Boolean; inline; + function StartOfDay: TDateTime; inline; + function StartOfMonth: TDateTime; inline; + function StartOfWeek: TDateTime; inline; + function StartOfYear: TDateTime; inline; + function ToString(const aFormatStr: string = ''): string; inline; + function WeeksBetween(const aDateTime: TDateTime): Integer; inline; + function WithinDays(const aDateTime: TDateTime; const aDays: Integer): Boolean; inline; + function WithinHours(const aDateTime: TDateTime; const aHours: Int64): Boolean; inline; + function WithinMilliseconds(const aDateTime: TDateTime; const AMilliseconds: Int64): Boolean; inline; + function WithinMinutes(const aDateTime: TDateTime; const aMinutes: Int64): Boolean; inline; + function WithinMonths(const aDateTime: TDateTime; const aMonths: Integer): Boolean; inline; + function WithinSeconds(const aDateTime: TDateTime; const aSeconds: Int64): Boolean; inline; + function WithinWeeks(const aDateTime: TDateTime; const aWeeks: Integer): Boolean; inline; + function WithinYears(const aDateTime: TDateTime; const aYears: Integer): Boolean; inline; + function YearsBetween(const aDateTime: TDateTime): Integer; inline; + class property Now: TDateTime read GetNow; + class property Today: TDateTime read GetToday; + class property Tomorrow: TDateTime read GetTomorrow; + class property Yesterday: TDateTime read GetYesterDay; + property Date: TDateTime read GetDate; + property Day: Word read GetDay; + property DayOfWeek: Word read GetDayOfWeek; + property DayOfYear: Word read GetDayOfYear; + property Hour: Word read GetHour; + property Millisecond: Word read GetMillisecond; + property Minute: Word read GetMinute; + property Month: Word read GetMonth; + property Second: Word read GetSecond; + property Time: TDateTime read GetTime; + property TotalSeconds: Int64 read GetTotalSecounds; + property UnixTime: Int64 read GetUnixTime; + property Year: Word read GetYear; end; implementation -{ TDateTimeHelper } +class function TDateTimeHelper.Create(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; +begin + Result := Parse(Date, aFormat, aDateSeparator, aTimeSeparator); +end; + +class function TDateTimeHelper.Create(const aYear, aMonth, aDay: Word): TDateTime; +begin + Result := EncodeDate(aYear, aMonth, aDay); +end; + +class function TDateTimeHelper.Create(const aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond: Word): TDateTime; +begin + Result := EncodeDateTime(aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond); +end; + +class function TDateTimeHelper.CreateLocal(Date: string; local: string = ''): TDateTime; +begin + Result:= ParseLocal(Date,local); +end; + +class function TDateTimeHelper.CreateTotalSeconds(const Value: Int64): TDateTime; +begin + Result := (Value / 86400); +end; + +class function TDateTimeHelper.CreateUnixTime(const Value: Int64): TDateTime; +begin + Result := (Value / 86400) + 25569; +end; + +class function TDateTimeHelper.GetNow: TDateTime; +begin + Result := System.SysUtils.Now; +end; + +class function TDateTimeHelper.GetToday: TDateTime; +begin + Result := System.SysUtils.Date; +end; + +class function TDateTimeHelper.GetTomorrow: TDateTime; +begin + Result := System.SysUtils.Date + 1; +end; + +class function TDateTimeHelper.GetYesterDay: TDateTime; +begin + Result := System.SysUtils.Date - 1; +end; + +class function TDateTimeHelper.Parse(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; +var + fs: TFormatSettings; + aFormats: TArray; + aLength: Integer; +begin + aFormats := aFormat.split([' ']); + + aLength := Length(aFormats); + + if aLength = 0 then + exit(StrToDateTime(Date)); + + GetLocaleFormatSettings(SysLocale.DefaultLCID, fs); + with fs do + begin + + if aDateSeparator <> #0 then + DateSeparator := aDateSeparator; + + if not aFormats[0].Trim.IsEmpty then + ShortDateFormat := aFormats[0]; + + if aLength > 1 then + begin + if aTimeSeparator <> #0 then + TimeSeparator := aTimeSeparator; + + if not aFormats[1].Trim.IsEmpty then + ShortTimeFormat := aFormats[1]; + end; + end; + Result := StrToDateTime(Date, fs); +end; + +class function TDateTimeHelper.ParseLocal(Date: string; local: string = ''): TDateTime; +var + fs: TFormatSettings; +begin + if local.Trim.IsEmpty then + fs := TFormatSettings.Create(SysLocale.DefaultLCID) + else + fs := TFormatSettings.Create(local); + + Result := StrToDateTime(Date, fs); +end; function TDateTimeHelper.AddDays(const aNumberOfDays: Integer): TDateTime; begin @@ -184,27 +273,6 @@ function TDateTimeHelper.CompareTo(const aDateTime: TDateTime): TValueRelationsh Result := CompareDateTime(Self, aDateTime); end; -class function TDateTimeHelper.Create(const aYear, aMonth, aDay: Word): TDateTime; -begin - Result := EncodeDate(aYear, aMonth, aDay); -end; - -class function TDateTimeHelper.Create(const aYear, aMonth, aDay, aHour, aMinute, - aSecond, aMillisecond: Word): TDateTime; -begin - Result := EncodeDateTime(aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond); -end; - -class function TDateTimeHelper.CreateTotalSeconds(const Value: Int64): TDateTime; -begin - Result := (Value / 86400); -end; - -class function TDateTimeHelper.CreateUnixTime(const Value: Int64): TDateTime; -begin - Result := (Value / 86400) + 25569; -end; - function TDateTimeHelper.DaysBetween(const aDateTime: TDateTime): Integer; begin Result := System.DateUtils.DaysBetween(Self, aDateTime); @@ -275,11 +343,6 @@ function TDateTimeHelper.GetMonth: Word; Result := MonthOf(Self); end; -class function TDateTimeHelper.GetNow: TDateTime; -begin - Result := System.SysUtils.Now; -end; - function TDateTimeHelper.GetSecond: Word; begin Result := SecondOf(Self); @@ -290,16 +353,6 @@ function TDateTimeHelper.GetTime: TDateTime; Result := TimeOf(Self); end; -class function TDateTimeHelper.GetToday: TDateTime; -begin - Result := System.SysUtils.Date; -end; - -class function TDateTimeHelper.GetTomorrow: TDateTime; -begin - Result := System.SysUtils.Date + 1; -end; - function TDateTimeHelper.GetTotalSecounds: Int64; begin Result := Trunc(86400 * self); @@ -315,18 +368,12 @@ function TDateTimeHelper.GetYear: Word; Result := YearOf(Self); end; -class function TDateTimeHelper.GetYesterDay: TDateTime; -begin - Result := System.SysUtils.Date - 1; -end; - function TDateTimeHelper.HoursBetween(const aDateTime: TDateTime): Int64; begin Result := System.DateUtils.HoursBetween(Self, aDateTime); end; -function TDateTimeHelper.InRange(const aStartDateTime, aEndDateTime: TDateTime; - const aInclusive: Boolean): Boolean; +function TDateTimeHelper.InRange(const aStartDateTime, aEndDateTime: TDateTime; const aInclusive: Boolean = True): Boolean; begin Result := DateTimeInRange(Self, aStartDateTime, aEndDateTime, aInclusive); end; @@ -409,50 +456,42 @@ function TDateTimeHelper.WeeksBetween(const aDateTime: TDateTime): Integer; Result := System.DateUtils.WeeksBetween(Self, aDateTime); end; -function TDateTimeHelper.WithinDays(const aDateTime: TDateTime; const aDays: - Integer): Boolean; +function TDateTimeHelper.WithinDays(const aDateTime: TDateTime; const aDays: Integer): Boolean; begin Result := System.DateUtils.WithinPastDays(Self, aDateTime, aDays); end; -function TDateTimeHelper.WithinHours(const aDateTime: TDateTime; const aHours: - Int64): Boolean; +function TDateTimeHelper.WithinHours(const aDateTime: TDateTime; const aHours: Int64): Boolean; begin Result := System.DateUtils.WithinPastHours(Self, aDateTime, aHours); end; -function TDateTimeHelper.WithinMilliseconds(const aDateTime: TDateTime; const - AMilliseconds: Int64): Boolean; +function TDateTimeHelper.WithinMilliseconds(const aDateTime: TDateTime; const AMilliseconds: Int64): Boolean; begin Result := System.DateUtils.WithinPastMilliSeconds(Self, aDateTime, AMilliseconds); end; -function TDateTimeHelper.WithinMinutes(const aDateTime: TDateTime; const - aMinutes: Int64): Boolean; +function TDateTimeHelper.WithinMinutes(const aDateTime: TDateTime; const aMinutes: Int64): Boolean; begin Result := System.DateUtils.WithinPastMinutes(Self, aDateTime, aMinutes); end; -function TDateTimeHelper.WithinMonths(const aDateTime: TDateTime; const aMonths: - Integer): Boolean; +function TDateTimeHelper.WithinMonths(const aDateTime: TDateTime; const aMonths: Integer): Boolean; begin Result := System.DateUtils.WithinPastMonths(Self, aDateTime, aMonths); end; -function TDateTimeHelper.WithinSeconds(const aDateTime: TDateTime; const - aSeconds: Int64): Boolean; +function TDateTimeHelper.WithinSeconds(const aDateTime: TDateTime; const aSeconds: Int64): Boolean; begin Result := System.DateUtils.WithinPastSeconds(Self, aDateTime, aSeconds); end; -function TDateTimeHelper.WithinWeeks(const aDateTime: TDateTime; const aWeeks: - Integer): Boolean; +function TDateTimeHelper.WithinWeeks(const aDateTime: TDateTime; const aWeeks: Integer): Boolean; begin Result := System.DateUtils.WithinPastWeeks(Self, aDateTime, aWeeks); end; -function TDateTimeHelper.WithinYears(const aDateTime: TDateTime; const aYears: - Integer): Boolean; +function TDateTimeHelper.WithinYears(const aDateTime: TDateTime; const aYears: Integer): Boolean; begin Result := System.DateUtils.WithinPastYears(Self, aDateTime, aYears); end; @@ -462,64 +501,5 @@ function TDateTimeHelper.YearsBetween(const aDateTime: TDateTime): Integer; Result := System.DateUtils.YearsBetween(Self, aDateTime); end; -class function TDateTimeHelper.Parse(Date: string; aFormat: string = ''; - aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; -var - fs: TFormatSettings; - aFormats: TArray; - aLength: Integer; -begin - aFormats := aFormat.split([' ']); - - aLength := Length(aFormats); - - if aLength = 0 then - exit(StrToDateTime(Date)); - - GetLocaleFormatSettings(SysLocale.DefaultLCID, fs); - with fs do - begin - - if aDateSeparator <> #0 then - DateSeparator := aDateSeparator; - - if not aFormats[0].Trim.IsEmpty then - ShortDateFormat := aFormats[0]; - - if aLength > 1 then - begin - if aTimeSeparator <> #0 then - TimeSeparator := aTimeSeparator; - - if not aFormats[1].Trim.IsEmpty then - ShortTimeFormat := aFormats[1]; - end; - end; - Result := StrToDateTime(Date, fs); -end; - -class function TDateTimeHelper.ParseLocal(Date: string; local: string = ''): TDateTime; -var - fs: TFormatSettings; -begin - if local.Trim.IsEmpty then - fs := TFormatSettings.Create(SysLocale.DefaultLCID) - else - fs := TFormatSettings.Create(local); - - Result := StrToDateTime(Date, fs); -end; - -class function TDateTimeHelper.Create(Date, aFormat: string; aDateSeparator, - aTimeSeparator: Char): TDateTime; -begin - Result := Parse(Date, aFormat, aDateSeparator, aTimeSeparator); -end; - -class function TDateTimeHelper.CreateLocal(Date, local: string): TDateTime; -begin - Result:= ParseLocal(Date,local); -end; - end. From 31adcd75b5f697c042c0e9bc74ed1bfa5d940b6e Mon Sep 17 00:00:00 2001 From: Cleber Moies Grings Date: Fri, 27 Sep 2024 06:57:25 +0200 Subject: [PATCH 3/4] - Rimuved A first Variable + const and Format --- DateTimeHelper.pas | 336 +++++++-------- Tests/TDateTimeHelper.Tests.pas | 19 + Tests/TDateTimeHelperTests.dproj | 698 +++++++++++++++---------------- 3 files changed, 522 insertions(+), 531 deletions(-) diff --git a/DateTimeHelper.pas b/DateTimeHelper.pas index 7d91023..88317c4 100755 --- a/DateTimeHelper.pas +++ b/DateTimeHelper.pas @@ -5,7 +5,7 @@ MIT License -Copyright (c) 2023 Colin Johnsun +Copyright (c) 2023 - 2024 Colin Johnsun Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -38,127 +38,130 @@ interface type TDateTimeHelper = record helper for TDateTime - private + function WithinDays(const DateTime: TDateTime; const Days: Int32): Boolean; inline; + strict private /// Parse a string as TDateTime, using a string format ex.('MM/dd/yyyy hh:mm:ss') /// TDateTime /// (string) - /// (string) - /// (Char) - /// (Char) - class function Parse(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; static; inline; - /// Parse a string as TDateTime, using local string ex. ('en-US') + /// (string) + /// (Char) + /// (Char) + class function Parse(const Date: string; const Format: string = ''; const DateSeparator: Char = #0; const TimeSeparator: Char = #0): TDateTime; static; inline; + /// Parse a string as TDateTime, using Local string ex. ('en-US') /// TDateTime /// (string) - /// (string) - class function ParseLocal(Date: string; local: string = ''): TDateTime; static; inline; + /// (string) + class function ParseLocal(const Date: string; const Local: string = ''): TDateTime; static; inline; function GetDate: TDateTime; inline; - function GetDay: Word; inline; - function GetDayOfWeek: Word; inline; - function GetDayOfYear: Word; inline; - function GetHour: Word; inline; - function GetMillisecond: Word; inline; - function GetMinute: Word; inline; - function GetMonth: Word; inline; + function GetDay: UInt16; inline; + function GetDayOfWeek: UInt16; inline; + function GetDayOfYear: UInt16; inline; + function GetHour: UInt16; inline; + function GetMillisecond: UInt16; inline; + function GetMinute: UInt16; inline; + function GetMonth: UInt16; inline; class function GetNow: TDateTime; static; inline; - function GetSecond: Word; inline; + function GetSecond: UInt16; inline; function GetTime: TDateTime; inline; class function GetToday: TDateTime; static; inline; class function GetTomorrow: TDateTime; static; inline; function GetTotalSecounds: Int64; function GetUnixTime: Int64; - function GetYear: Word; inline; + function GetYear: UInt16; inline; class function GetYesterDay: TDateTime; static; inline; public - class function Create(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; overload; static; inline; - class function Create(const aYear, aMonth, aDay: Word): TDateTime; overload; static; inline; - class function Create(const aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond: Word): TDateTime; overload; static; inline; - class function CreateLocal(Date: string; local: string = ''): TDateTime; static; inline; + class function Create(const Date: string; const Format: string = ''; const DateSeparator: Char = #0; const TimeSeparator: Char = #0): TDateTime; overload; + static; inline; + class function Create(const Year, Month, Day: UInt16): TDateTime; overload; static; inline; + class function Create(const Year, Month, Day, Hour, Minute, Second, Millisecond: UInt16): TDateTime; overload; static; inline; + class function CreateLocal(const Date, Local: string): TDateTime; static; inline; class function CreateTotalSeconds(const Value: Int64): TDateTime; static; inline; class function CreateUnixTime(const Value: Int64): TDateTime; static; inline; - function AddDays(const aNumberOfDays: Integer = 1): TDateTime; inline; - function AddHours(const aNumberOfHours: Int64 = 1): TDateTime; inline; - function AddMilliseconds(const aNumberOfMilliseconds: Int64 = 1): TDateTime; inline; - function AddMinutes(const aNumberOfMinutes: Int64 = 1): TDateTime; inline; - function AddMonths(const aNumberOfMonths: Integer = 1): TDateTime; inline; - function AddSeconds(const aNumberOfSeconds: Int64 = 1): TDateTime; inline; - function AddYears(const aNumberOfYears: Integer = 1): TDateTime; inline; - function CompareTo(const aDateTime: TDateTime): TValueRelationship; inline; - function DaysBetween(const aDateTime: TDateTime): Integer; inline; + function AddDays(const NumberOfDays: Int32 = 1): TDateTime; inline; + function AddHours(const NumberOfHours: Int64 = 1): TDateTime; inline; + function AddMilliseconds(const NumberOfMilliseconds: Int64 = 1): TDateTime; inline; + function AddMinutes(const NumberOfMinutes: Int64 = 1): TDateTime; inline; + function AddMonths(const NumberOfMonths: Int32 = 1): TDateTime; inline; + function AddSeconds(const NumberOfSeconds: Int64 = 1): TDateTime; inline; + function AddYears(const NumberOfYears: Int32 = 1): TDateTime; inline; + function AsDouble: Double; overload; + procedure AsDouble(const Value: Double); overload; + function CompareTo(const DateTime: TDateTime): TValueRelationship; inline; + function DaysBetween(const DateTime: TDateTime): Integer; inline; function EndOfDay: TDateTime; inline; function EndOfMonth: TDateTime; inline; function EndOfWeek: TDateTime; inline; function EndOfYear: TDateTime; inline; - function Equals(const aDateTime: TDateTime): Boolean; inline; - function HoursBetween(const aDateTime: TDateTime): Int64; inline; - function InRange(const aStartDateTime, aEndDateTime: TDateTime; const aInclusive: Boolean = True): Boolean; inline; + function Equals(const DateTime: TDateTime): Boolean; inline; + function HoursBetween(const DateTime: TDateTime): Int64; inline; + function InRange(const StartDateTime, EndDateTime: TDateTime; const Inclusive: Boolean = True): Boolean; inline; function IsAM: Boolean; inline; function IsInLeapYear: Boolean; inline; function IsPM: Boolean; inline; - function IsSameDay(const aDateTime: TDateTime): Boolean; inline; + function IsSameDay(const DateTime: TDateTime): Boolean; inline; function IsToday: Boolean; inline; - function MilliSecondsBetween(const aDateTime: TDateTime): Int64; inline; - function MinutesBetween(const aDateTime: TDateTime): Int64; inline; - function MonthsBetween(const aDateTime: TDateTime): Integer; inline; - function SecondsBetween(const aDateTime: TDateTime): Int64; inline; + function MilliSecondsBetween(const DateTime: TDateTime): Int64; inline; + function MinutesBetween(const DateTime: TDateTime): Int64; inline; + function MonthsBetween(const DateTime: TDateTime): Integer; inline; + function SecondsBetween(const DateTime: TDateTime): Int64; inline; function StartOfDay: TDateTime; inline; function StartOfMonth: TDateTime; inline; function StartOfWeek: TDateTime; inline; function StartOfYear: TDateTime; inline; - function ToString(const aFormatStr: string = ''): string; inline; - function WeeksBetween(const aDateTime: TDateTime): Integer; inline; - function WithinDays(const aDateTime: TDateTime; const aDays: Integer): Boolean; inline; - function WithinHours(const aDateTime: TDateTime; const aHours: Int64): Boolean; inline; - function WithinMilliseconds(const aDateTime: TDateTime; const AMilliseconds: Int64): Boolean; inline; - function WithinMinutes(const aDateTime: TDateTime; const aMinutes: Int64): Boolean; inline; - function WithinMonths(const aDateTime: TDateTime; const aMonths: Integer): Boolean; inline; - function WithinSeconds(const aDateTime: TDateTime; const aSeconds: Int64): Boolean; inline; - function WithinWeeks(const aDateTime: TDateTime; const aWeeks: Integer): Boolean; inline; - function WithinYears(const aDateTime: TDateTime; const aYears: Integer): Boolean; inline; - function YearsBetween(const aDateTime: TDateTime): Integer; inline; + function ToString(const FormatStr: string = ''): string; inline; + function WeeksBetween(const DateTime: TDateTime): Int32; inline; + function WithinHours(const DateTime: TDateTime; const Hours: Int64): Boolean; inline; + function WithinMilliseconds(const DateTime: TDateTime; const Milliseconds: Int64): Boolean; inline; + function WithinMinutes(const DateTime: TDateTime; const Minutes: Int64): Boolean; inline; + function WithinMonths(const DateTime: TDateTime; const Months: Int32): Boolean; inline; + function WithinSeconds(const DateTime: TDateTime; const Seconds: Int64): Boolean; inline; + function WithinWeeks(const DateTime: TDateTime; const Weeks: Int32): Boolean; inline; + function WithinYears(const DateTime: TDateTime; const Years: Int32): Boolean; inline; + function YearsBetween(const DateTime: TDateTime): Int32; inline; class property Now: TDateTime read GetNow; class property Today: TDateTime read GetToday; class property Tomorrow: TDateTime read GetTomorrow; class property Yesterday: TDateTime read GetYesterDay; property Date: TDateTime read GetDate; - property Day: Word read GetDay; - property DayOfWeek: Word read GetDayOfWeek; - property DayOfYear: Word read GetDayOfYear; - property Hour: Word read GetHour; - property Millisecond: Word read GetMillisecond; - property Minute: Word read GetMinute; - property Month: Word read GetMonth; - property Second: Word read GetSecond; + property Day: UInt16 read GetDay; + property DayOfWeek: UInt16 read GetDayOfWeek; + property DayOfYear: UInt16 read GetDayOfYear; + property Hour: UInt16 read GetHour; + property Millisecond: UInt16 read GetMillisecond; + property Minute: UInt16 read GetMinute; + property Month: UInt16 read GetMonth; + property Second: UInt16 read GetSecond; property Time: TDateTime read GetTime; property TotalSeconds: Int64 read GetTotalSecounds; property UnixTime: Int64 read GetUnixTime; - property Year: Word read GetYear; + property Year: UInt16 read GetYear; end; implementation -class function TDateTimeHelper.Create(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; +class function TDateTimeHelper.Create(const Date: string; const Format: string = ''; const DateSeparator: Char = #0; const TimeSeparator: Char = #0): TDateTime; begin - Result := Parse(Date, aFormat, aDateSeparator, aTimeSeparator); + Result := Parse(Date, Format, DateSeparator, TimeSeparator); end; -class function TDateTimeHelper.Create(const aYear, aMonth, aDay: Word): TDateTime; +class function TDateTimeHelper.Create(const Year, Month, Day: UInt16): TDateTime; begin - Result := EncodeDate(aYear, aMonth, aDay); + Result := EncodeDate(Year, Month, Day); end; -class function TDateTimeHelper.Create(const aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond: Word): TDateTime; +class function TDateTimeHelper.Create(const Year, Month, Day, Hour, Minute, Second, Millisecond: UInt16): TDateTime; begin - Result := EncodeDateTime(aYear, aMonth, aDay, aHour, aMinute, aSecond, aMillisecond); + Result := EncodeDateTime(Year, Month, Day, Hour, Minute, Second, Millisecond); end; -class function TDateTimeHelper.CreateLocal(Date: string; local: string = ''): TDateTime; +class function TDateTimeHelper.CreateLocal(const Date, Local: string): TDateTime; begin - Result:= ParseLocal(Date,local); + Result:= ParseLocal(Date, Local); end; class function TDateTimeHelper.CreateTotalSeconds(const Value: Int64): TDateTime; begin - Result := (Value / 86400); + Result := Value / 86400; end; class function TDateTimeHelper.CreateUnixTime(const Value: Int64): TDateTime; @@ -178,104 +181,109 @@ class function TDateTimeHelper.GetToday: TDateTime; class function TDateTimeHelper.GetTomorrow: TDateTime; begin - Result := System.SysUtils.Date + 1; + Result := IncDay(System.SysUtils.Date); end; class function TDateTimeHelper.GetYesterDay: TDateTime; begin - Result := System.SysUtils.Date - 1; + Result := IncDay(System.SysUtils.Date, - 1); end; -class function TDateTimeHelper.Parse(Date: string; aFormat: string = ''; aDateSeparator: Char = #0; aTimeSeparator: Char = #0): TDateTime; -var - fs: TFormatSettings; - aFormats: TArray; - aLength: Integer; +class function TDateTimeHelper.Parse(const Date: string; const Format: string = ''; const DateSeparator: Char = #0; const TimeSeparator: Char = #0): TDateTime; begin - aFormats := aFormat.split([' ']); + var Formats: TArray := Format.Split([' ']); + var LengthFormats := Length(Formats); - aLength := Length(aFormats); - - if aLength = 0 then - exit(StrToDateTime(Date)); - - GetLocaleFormatSettings(SysLocale.DefaultLCID, fs); - with fs do + if LengthFormats = 0 then + Result := StrToDateTime(Date) + else begin + var fs := TFormatSettings.Create(SysLocale.DefaultLCID); - if aDateSeparator <> #0 then - DateSeparator := aDateSeparator; + if DateSeparator <> #0 then + fs.DateSeparator := DateSeparator; - if not aFormats[0].Trim.IsEmpty then - ShortDateFormat := aFormats[0]; + if not Formats[0].Trim.IsEmpty then + fs.ShortDateFormat := Formats[0]; - if aLength > 1 then + if LengthFormats > 1 then begin - if aTimeSeparator <> #0 then - TimeSeparator := aTimeSeparator; + if TimeSeparator <> #0 then + fs.TimeSeparator := TimeSeparator; - if not aFormats[1].Trim.IsEmpty then - ShortTimeFormat := aFormats[1]; + if not Formats[1].Trim.IsEmpty then + fs.ShortTimeFormat := Formats[1]; end; + + Result := StrToDateTime(Date, fs); end; - Result := StrToDateTime(Date, fs); end; -class function TDateTimeHelper.ParseLocal(Date: string; local: string = ''): TDateTime; -var - fs: TFormatSettings; +class function TDateTimeHelper.ParseLocal(const Date: string; const Local: string = ''): TDateTime; begin - if local.Trim.IsEmpty then + var fs: TFormatSettings; + + if Local.Trim.IsEmpty then fs := TFormatSettings.Create(SysLocale.DefaultLCID) else - fs := TFormatSettings.Create(local); + fs := TFormatSettings.Create(Local); Result := StrToDateTime(Date, fs); end; -function TDateTimeHelper.AddDays(const aNumberOfDays: Integer): TDateTime; +function TDateTimeHelper.AddDays(const NumberOfDays: Int32 = 1): TDateTime; +begin + Result := IncDay(Self, NumberOfDays); +end; + +function TDateTimeHelper.AddHours(const NumberOfHours: Int64 = 1): TDateTime; +begin + Result := IncHour(Self, NumberOfHours); +end; + +function TDateTimeHelper.AddMilliseconds(const NumberOfMilliseconds: Int64 = 1): TDateTime; begin - Result := IncDay(Self, aNumberOfDays); + Result := IncMilliSecond(Self, NumberOfMilliseconds); end; -function TDateTimeHelper.AddHours(const aNumberOfHours: Int64): TDateTime; +function TDateTimeHelper.AddMinutes(const NumberOfMinutes: Int64 = 1): TDateTime; begin - Result := IncHour(Self, aNumberOfHours); + Result := IncMinute(Self, NumberOfMinutes); end; -function TDateTimeHelper.AddMilliseconds(const aNumberOfMilliseconds: Int64): TDateTime; +function TDateTimeHelper.AddMonths(const NumberOfMonths: Int32 = 1): TDateTime; begin - Result := IncMilliSecond(Self, aNumberOfMilliseconds); + Result := IncMonth(Self, NumberOfMonths); end; -function TDateTimeHelper.AddMinutes(const aNumberOfMinutes: Int64): TDateTime; +function TDateTimeHelper.AddSeconds(const NumberOfSeconds: Int64 = 1): TDateTime; begin - Result := IncMinute(Self, aNumberOfMinutes); + Result := IncSecond(Self, NumberOfSeconds); end; -function TDateTimeHelper.AddMonths(const aNumberOfMonths: Integer): TDateTime; +function TDateTimeHelper.AddYears(const NumberOfYears: Int32 = 1): TDateTime; begin - Result := IncMonth(Self, aNumberOfMonths); + Result := IncYear(Self, NumberOfYears); end; -function TDateTimeHelper.AddSeconds(const aNumberOfSeconds: Int64): TDateTime; +function TDateTimeHelper.AsDouble: Double; begin - Result := IncSecond(Self, aNumberOfSeconds); + Result := Self; end; -function TDateTimeHelper.AddYears(const aNumberOfYears: Integer): TDateTime; +procedure TDateTimeHelper.AsDouble(const Value: Double); begin - Result := IncYear(Self, aNumberOfYears); + Self := Value; end; -function TDateTimeHelper.CompareTo(const aDateTime: TDateTime): TValueRelationship; +function TDateTimeHelper.CompareTo(const DateTime: TDateTime): TValueRelationship; begin - Result := CompareDateTime(Self, aDateTime); + Result := CompareDateTime(Self, DateTime); end; -function TDateTimeHelper.DaysBetween(const aDateTime: TDateTime): Integer; +function TDateTimeHelper.DaysBetween(const DateTime: TDateTime): Integer; begin - Result := System.DateUtils.DaysBetween(Self, aDateTime); + Result := System.DateUtils.DaysBetween(Self, DateTime); end; function TDateTimeHelper.EndOfDay: TDateTime; @@ -298,9 +306,9 @@ function TDateTimeHelper.EndOfYear: TDateTime; Result := EndOfTheYear(Self); end; -function TDateTimeHelper.Equals(const aDateTime: TDateTime): Boolean; +function TDateTimeHelper.Equals(const DateTime: TDateTime): Boolean; begin - Result := SameDateTime(Self, aDateTime); + Result := SameDateTime(Self, DateTime); end; function TDateTimeHelper.GetDate: TDateTime; @@ -308,42 +316,42 @@ function TDateTimeHelper.GetDate: TDateTime; Result := DateOf(Self); end; -function TDateTimeHelper.GetDay: Word; +function TDateTimeHelper.GetDay: UInt16; begin Result := DayOf(Self); end; -function TDateTimeHelper.GetDayOfWeek: Word; +function TDateTimeHelper.GetDayOfWeek: UInt16; begin Result := DayOfTheWeek(Self); end; -function TDateTimeHelper.GetDayOfYear: Word; +function TDateTimeHelper.GetDayOfYear: UInt16; begin Result := DayOfTheYear(Self); end; -function TDateTimeHelper.GetHour: Word; +function TDateTimeHelper.GetHour: UInt16; begin Result := HourOf(Self); end; -function TDateTimeHelper.GetMillisecond: Word; +function TDateTimeHelper.GetMillisecond: UInt16; begin Result := MilliSecondOf(Self); end; -function TDateTimeHelper.GetMinute: Word; +function TDateTimeHelper.GetMinute: UInt16; begin Result := MinuteOf(Self); end; -function TDateTimeHelper.GetMonth: Word; +function TDateTimeHelper.GetMonth: UInt16; begin Result := MonthOf(Self); end; -function TDateTimeHelper.GetSecond: Word; +function TDateTimeHelper.GetSecond: UInt16; begin Result := SecondOf(Self); end; @@ -363,19 +371,19 @@ function TDateTimeHelper.GetUnixTime: Int64; Result := Trunc((self - 25569) * 86400); end; -function TDateTimeHelper.GetYear: Word; +function TDateTimeHelper.GetYear: UInt16; begin Result := YearOf(Self); end; -function TDateTimeHelper.HoursBetween(const aDateTime: TDateTime): Int64; +function TDateTimeHelper.HoursBetween(const DateTime: TDateTime): Int64; begin - Result := System.DateUtils.HoursBetween(Self, aDateTime); + Result := System.DateUtils.HoursBetween(Self, DateTime); end; -function TDateTimeHelper.InRange(const aStartDateTime, aEndDateTime: TDateTime; const aInclusive: Boolean = True): Boolean; +function TDateTimeHelper.InRange(const StartDateTime, EndDateTime: TDateTime; const Inclusive: Boolean = True): Boolean; begin - Result := DateTimeInRange(Self, aStartDateTime, aEndDateTime, aInclusive); + Result := DateTimeInRange(Self, StartDateTime, EndDateTime, Inclusive); end; function TDateTimeHelper.IsAM: Boolean; @@ -393,9 +401,9 @@ function TDateTimeHelper.IsPM: Boolean; Result := System.DateUtils.IsPM(Self); end; -function TDateTimeHelper.IsSameDay(const aDateTime: TDateTime): Boolean; +function TDateTimeHelper.IsSameDay(const DateTime: TDateTime): Boolean; begin - Result := System.DateUtils.IsSameDay(Self, aDateTime); + Result := System.DateUtils.IsSameDay(Self, DateTime); end; function TDateTimeHelper.IsToday: Boolean; @@ -403,24 +411,24 @@ function TDateTimeHelper.IsToday: Boolean; Result := System.DateUtils.IsToday(Self); end; -function TDateTimeHelper.MilliSecondsBetween(const aDateTime: TDateTime): Int64; +function TDateTimeHelper.MilliSecondsBetween(const DateTime: TDateTime): Int64; begin - Result := System.DateUtils.MilliSecondsBetween(Self, aDateTime); + Result := System.DateUtils.MilliSecondsBetween(Self, DateTime); end; -function TDateTimeHelper.MinutesBetween(const aDateTime: TDateTime): Int64; +function TDateTimeHelper.MinutesBetween(const DateTime: TDateTime): Int64; begin - Result := System.DateUtils.MinutesBetween(Self, aDateTime); + Result := System.DateUtils.MinutesBetween(Self, DateTime); end; -function TDateTimeHelper.MonthsBetween(const aDateTime: TDateTime): Integer; +function TDateTimeHelper.MonthsBetween(const DateTime: TDateTime): Integer; begin - Result := System.DateUtils.MonthsBetween(Self, aDateTime); + Result := System.DateUtils.MonthsBetween(Self, DateTime); end; -function TDateTimeHelper.SecondsBetween(const aDateTime: TDateTime): Int64; +function TDateTimeHelper.SecondsBetween(const DateTime: TDateTime): Int64; begin - Result := System.DateUtils.SecondsBetween(Self, aDateTime); + Result := System.DateUtils.SecondsBetween(Self, DateTime); end; function TDateTimeHelper.StartOfDay: TDateTime; @@ -443,62 +451,62 @@ function TDateTimeHelper.StartOfYear: TDateTime; Result := StartOfTheYear(Self); end; -function TDateTimeHelper.ToString(const aFormatStr: string): string; +function TDateTimeHelper.ToString(const FormatStr: string = ''): string; begin - if aFormatStr = '' then + if FormatStr.IsEmpty then Result := DateToStr(Self) else - Result := FormatDateTime(aFormatStr, Self); + Result := FormatDateTime(FormatStr, Self); end; -function TDateTimeHelper.WeeksBetween(const aDateTime: TDateTime): Integer; +function TDateTimeHelper.WeeksBetween(const DateTime: TDateTime): Int32; begin - Result := System.DateUtils.WeeksBetween(Self, aDateTime); + Result := System.DateUtils.WeeksBetween(Self, DateTime); end; -function TDateTimeHelper.WithinDays(const aDateTime: TDateTime; const aDays: Integer): Boolean; +function TDateTimeHelper.WithinDays(const DateTime: TDateTime; const Days: Int32): Boolean; begin - Result := System.DateUtils.WithinPastDays(Self, aDateTime, aDays); + Result := System.DateUtils.WithinPastDays(Self, DateTime, Days); end; -function TDateTimeHelper.WithinHours(const aDateTime: TDateTime; const aHours: Int64): Boolean; +function TDateTimeHelper.WithinHours(const DateTime: TDateTime; const Hours: Int64): Boolean; begin - Result := System.DateUtils.WithinPastHours(Self, aDateTime, aHours); + Result := System.DateUtils.WithinPastHours(Self, DateTime, Hours); end; -function TDateTimeHelper.WithinMilliseconds(const aDateTime: TDateTime; const AMilliseconds: Int64): Boolean; +function TDateTimeHelper.WithinMilliseconds(const DateTime: TDateTime; const Milliseconds: Int64): Boolean; begin - Result := System.DateUtils.WithinPastMilliSeconds(Self, aDateTime, AMilliseconds); + Result := System.DateUtils.WithinPastMilliSeconds(Self, DateTime, Milliseconds); end; -function TDateTimeHelper.WithinMinutes(const aDateTime: TDateTime; const aMinutes: Int64): Boolean; +function TDateTimeHelper.WithinMinutes(const DateTime: TDateTime; const Minutes: Int64): Boolean; begin - Result := System.DateUtils.WithinPastMinutes(Self, aDateTime, aMinutes); + Result := System.DateUtils.WithinPastMinutes(Self, DateTime, Minutes); end; -function TDateTimeHelper.WithinMonths(const aDateTime: TDateTime; const aMonths: Integer): Boolean; +function TDateTimeHelper.WithinMonths(const DateTime: TDateTime; const Months: Int32): Boolean; begin - Result := System.DateUtils.WithinPastMonths(Self, aDateTime, aMonths); + Result := System.DateUtils.WithinPastMonths(Self, DateTime, Months); end; -function TDateTimeHelper.WithinSeconds(const aDateTime: TDateTime; const aSeconds: Int64): Boolean; +function TDateTimeHelper.WithinSeconds(const DateTime: TDateTime; const Seconds: Int64): Boolean; begin - Result := System.DateUtils.WithinPastSeconds(Self, aDateTime, aSeconds); + Result := System.DateUtils.WithinPastSeconds(Self, DateTime, Seconds); end; -function TDateTimeHelper.WithinWeeks(const aDateTime: TDateTime; const aWeeks: Integer): Boolean; +function TDateTimeHelper.WithinWeeks(const DateTime: TDateTime; const Weeks: Int32): Boolean; begin - Result := System.DateUtils.WithinPastWeeks(Self, aDateTime, aWeeks); + Result := System.DateUtils.WithinPastWeeks(Self, DateTime, Weeks); end; -function TDateTimeHelper.WithinYears(const aDateTime: TDateTime; const aYears: Integer): Boolean; +function TDateTimeHelper.WithinYears(const DateTime: TDateTime; const Years: Int32): Boolean; begin - Result := System.DateUtils.WithinPastYears(Self, aDateTime, aYears); + Result := System.DateUtils.WithinPastYears(Self, DateTime, Years); end; -function TDateTimeHelper.YearsBetween(const aDateTime: TDateTime): Integer; +function TDateTimeHelper.YearsBetween(const DateTime: TDateTime): Int32; begin - Result := System.DateUtils.YearsBetween(Self, aDateTime); + Result := System.DateUtils.YearsBetween(Self, DateTime); end; end. diff --git a/Tests/TDateTimeHelper.Tests.pas b/Tests/TDateTimeHelper.Tests.pas index 1a14a86..ecd5ac5 100755 --- a/Tests/TDateTimeHelper.Tests.pas +++ b/Tests/TDateTimeHelper.Tests.pas @@ -62,6 +62,10 @@ TDateTimeHelperTestObject = class(TObject) procedure DateTime_TotalSecounds; [Test] procedure DateTime_UnixTime; + [Test] + procedure AsDoubleSet; + [Test] + procedure AsDoubleGet; end; implementation @@ -249,6 +253,21 @@ procedure TDateTimeHelperTestObject.DateTime_UnixTime; Assert.AreEqual(Expected, Actual); end; +procedure TDateTimeHelperTestObject.AsDoubleSet; +begin + var Expected: Double := FExpected; + var Actual := FActual.AsDouble; + Assert.AreEqual(Expected, Double(Actual)); +end; + +procedure TDateTimeHelperTestObject.AsDoubleGet; +begin + var Expected: Double := FExpected; + var Actual: TDateTime; + Actual.AsDouble(FActual); + Assert.AreEqual(Expected, FActual); +end; + initialization TDUnitX.RegisterTestFixture(TDateTimeHelperTestObject); diff --git a/Tests/TDateTimeHelperTests.dproj b/Tests/TDateTimeHelperTests.dproj index f645d1a..2d78f44 100755 --- a/Tests/TDateTimeHelperTests.dproj +++ b/Tests/TDateTimeHelperTests.dproj @@ -1,7 +1,7 @@  {E992A111-A05C-4625-AB5A-2B563821B4BE} - 18.8 + 20.1 None TDateTimeHelperTests.dpr True @@ -9,40 +9,11 @@ Win32 1 Console + TDateTimeHelperTests true - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - - - true - Base - true - true Base @@ -69,18 +40,6 @@ Base true - - true - Cfg_2 - true - true - - - true - Cfg_2 - true - true - $(DUnitX);$(DCC_UnitSearchPath) bindcompfmx;fmx;rtl;dbrtl;IndySystem;DbxClientDriver;bindcomp;inetdb;DBXInterBaseDriver;xmlrtl;ibxpress;DbxCommonDriver;IndyProtocols;DBXMySQLDriver;dbxcds;soaprtl;bindengine;FMXTee;dsnap;IndyCore;fmxase;CloudService;FmxTeeUI;inet;fmxobj;inetdbxpress;fmxdae;dbexpress;$(DCC_UsePackage) @@ -95,100 +54,11 @@ false TDateTimeHelperTests $(BDS)\bin\delphi_PROJECTICNS.icns - - - package=com.embarcadero.$(MSBuildProjectName);label=$(MSBuildProjectName);versionCode=1;versionName=1.0.0;persistent=False;restoreAnyVersion=False;installLocation=auto;largeHeap=False;theme=TitleBar;hardwareAccelerated=true;apiKey= - Debug - $(BDS)\bin\Artwork\Android\FM_LauncherIcon_36x36.png - $(BDS)\bin\Artwork\Android\FM_LauncherIcon_48x48.png - $(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png - $(BDS)\bin\Artwork\Android\FM_LauncherIcon_96x96.png - $(BDS)\bin\Artwork\Android\FM_LauncherIcon_144x144.png - $(BDS)\bin\Artwork\Android\FM_SplashImage_426x320.png - $(BDS)\bin\Artwork\Android\FM_SplashImage_470x320.png - $(BDS)\bin\Artwork\Android\FM_SplashImage_640x480.png - $(BDS)\bin\Artwork\Android\FM_SplashImage_960x720.png - true - true - true - true - true - true - true - true - true - true - $(BDS)\bin\Artwork\Android\FM_NotificationIcon_24x24.png - $(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png - $(BDS)\bin\Artwork\Android\FM_NotificationIcon_48x48.png - $(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png - $(BDS)\bin\Artwork\Android\FM_NotificationIcon_96x96.png - android-support-v4.dex.jar;cloud-messaging.dex.jar;com-google-android-gms.play-services-ads-base.17.2.0.dex.jar;com-google-android-gms.play-services-ads-identifier.16.0.0.dex.jar;com-google-android-gms.play-services-ads-lite.17.2.0.dex.jar;com-google-android-gms.play-services-ads.17.2.0.dex.jar;com-google-android-gms.play-services-analytics-impl.16.0.8.dex.jar;com-google-android-gms.play-services-analytics.16.0.8.dex.jar;com-google-android-gms.play-services-base.16.0.1.dex.jar;com-google-android-gms.play-services-basement.16.2.0.dex.jar;com-google-android-gms.play-services-gass.17.2.0.dex.jar;com-google-android-gms.play-services-identity.16.0.0.dex.jar;com-google-android-gms.play-services-maps.16.1.0.dex.jar;com-google-android-gms.play-services-measurement-base.16.4.0.dex.jar;com-google-android-gms.play-services-measurement-sdk-api.16.4.0.dex.jar;com-google-android-gms.play-services-stats.16.0.1.dex.jar;com-google-android-gms.play-services-tagmanager-v4-impl.16.0.8.dex.jar;com-google-android-gms.play-services-tasks.16.0.1.dex.jar;com-google-android-gms.play-services-wallet.16.0.1.dex.jar;com-google-firebase.firebase-analytics.16.4.0.dex.jar;com-google-firebase.firebase-common.16.1.0.dex.jar;com-google-firebase.firebase-iid-interop.16.0.1.dex.jar;com-google-firebase.firebase-iid.17.1.1.dex.jar;com-google-firebase.firebase-measurement-connector.17.0.1.dex.jar;com-google-firebase.firebase-messaging.17.5.0.dex.jar;fmx.dex.jar;google-play-billing.dex.jar;google-play-licensing.dex.jar - - - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;FMLocalNotificationPermission=false;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false - iPhoneAndiPad - true - Debug - $(MSBuildProjectName) - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_60x60.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_76x76.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImagePortrait_768x1024.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageLandscape_1024x768.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImagePortrait_1536x2048.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageLandscape_2048x1536.png - - - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;FMLocalNotificationPermission=false;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false - iPhoneAndiPad - true - Debug - $(MSBuildProjectName) - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_60x60.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_76x76.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImagePortrait_768x1024.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageLandscape_1024x768.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImagePortrait_1536x2048.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageLandscape_2048x1536.png - - - CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;CFBundleResourceSpecification=ResourceRules.plist;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;FMLocalNotificationPermission=false;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false - iPhoneAndiPad - true - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_60x60.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_40x40.png - $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_76x76.png - $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImagePortrait_768x1024.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageLandscape_1024x768.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImagePortrait_1536x2048.png - $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageLandscape_2048x1536.png - - - $(BDS)\bin\delphi_PROJECTICNS.icns - - - CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts - Debug - true - Base - true + TESTINSIGHT;EUREKALOG_VER7;EUREKALOG;$(DCC_Define) + 1040 + CompanyName=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductVersion=1.0.0.0;Comments=;ProgramID=com.embarcadero.$(MSBuildProjectName);FileDescription=$(MSBuildProjectName);ProductName=$(MSBuildProjectName) + 3 + true vcldbx;frx16;TeeDB;vclib;inetdbbde;Tee;svnui;vclimg;frxDB16;intrawebdb_120_160;fmi;fs16;vclactnband;TeeUI;vcldb;bindcompvcl;vcldsnap;vclie;vcltouch;Intraweb_120_160;websnap;vclribbon;frxe16;VclSmp;fsDB16;vcl;CodeSiteExpressPkg;dsnapcon;vclx;webdsnap;svn;bdertl;adortl;$(DCC_UsePackage) @@ -208,6 +78,9 @@ false + 1033 + (None) + none false @@ -215,24 +88,12 @@ 0 0 - - $(BDS)\bin\delphi_PROJECTICNS.icns - - - true - Cfg_2 - true - MainSource - - Cfg_2 - Base - Base @@ -240,6 +101,10 @@ Cfg_1 Base + + Cfg_2 + Base + Delphi.Personality.12 @@ -276,13 +141,12 @@ TDateTimeHelperTests.dpr + + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + - - - - true - - + true @@ -293,6 +157,11 @@ true + + + true + + 1 @@ -301,14 +170,14 @@ 0 - + classes - 1 + 64 classes - 1 + 64 @@ -321,12 +190,6 @@ 1 - - - library\lib\armeabi-v7a - 1 - - library\lib\armeabi @@ -379,6 +242,16 @@ 1 + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + + res\values @@ -399,6 +272,66 @@ 1 + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + res\values @@ -409,6 +342,16 @@ 1 + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + + res\drawable @@ -429,6 +372,16 @@ 1 + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + res\drawable-ldpi @@ -569,6 +522,56 @@ 1 + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + + 1 @@ -589,6 +592,10 @@ 1 .framework + + 1 + .framework + 0 @@ -602,6 +609,10 @@ 1 .dylib + + 1 + .dylib + 0 .dll;.bpl @@ -616,7 +627,7 @@ 1 .dylib - + 1 .dylib @@ -628,6 +639,10 @@ 1 .dylib + + 1 + .dylib + 0 .bpl @@ -646,7 +661,7 @@ 0 - + 0 @@ -655,403 +670,352 @@ 0 + + 0 + 0 - - - 1 - - + + 1 - + 1 - - + + + + + + Contents\Resources 1 - + + Contents\Resources 1 - + + Contents\Resources 1 - - - 1 - - + + + library\lib\armeabi-v7a 1 - + + library\lib\arm64-v8a 1 - - 1 1 - - 1 - - - - + 1 - + 1 - + 1 - - - + 1 - + 1 - - 1 + + 0 - - - 1 - - - 1 - - + + + library\lib\armeabi-v7a 1 - - + + 1 - + 1 - + 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + + + 1 1 - + 1 - - - 1 - - + + + Assets 1 - + + Assets 1 - - - 1 - - + + + Assets 1 - + + Assets 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - + - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - - - - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - - - - Contents\Resources + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Contents\Resources + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - library\lib\armeabi-v7a - 1 - - - library\lib\arm64-v8a - 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - 1 - - - 1 - - - 1 - - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - 0 - - - - library\lib\armeabi-v7a + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - - 1 - - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - Assets + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Assets + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - Assets + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Assets + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + + + + - - - - + + + + - False - False - False - False - False - False - False True False From 983e5bb3457f4b81138d91cc84e821e6ec2f16b1 Mon Sep 17 00:00:00 2001 From: Cleber Moies Grings Date: Tue, 12 Nov 2024 06:06:38 +0100 Subject: [PATCH 4/4] Change the name of variabile --- DateTimeHelper.pas | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/DateTimeHelper.pas b/DateTimeHelper.pas index 88317c4..6f439c7 100755 --- a/DateTimeHelper.pas +++ b/DateTimeHelper.pas @@ -198,37 +198,37 @@ class function TDateTimeHelper.Parse(const Date: string; const Format: string = Result := StrToDateTime(Date) else begin - var fs := TFormatSettings.Create(SysLocale.DefaultLCID); + var FormatSetting := TFormatSettings.Create(SysLocale.DefaultLCID); if DateSeparator <> #0 then - fs.DateSeparator := DateSeparator; + FormatSetting.DateSeparator := DateSeparator; if not Formats[0].Trim.IsEmpty then - fs.ShortDateFormat := Formats[0]; + FormatSetting.ShortDateFormat := Formats[0]; if LengthFormats > 1 then begin if TimeSeparator <> #0 then - fs.TimeSeparator := TimeSeparator; + FormatSetting.TimeSeparator := TimeSeparator; if not Formats[1].Trim.IsEmpty then - fs.ShortTimeFormat := Formats[1]; + FormatSetting.ShortTimeFormat := Formats[1]; end; - Result := StrToDateTime(Date, fs); + Result := StrToDateTime(Date, FormatSetting); end; end; class function TDateTimeHelper.ParseLocal(const Date: string; const Local: string = ''): TDateTime; begin - var fs: TFormatSettings; + var FormatSetting: TFormatSettings; if Local.Trim.IsEmpty then - fs := TFormatSettings.Create(SysLocale.DefaultLCID) + FormatSetting := TFormatSettings.Create(SysLocale.DefaultLCID) else - fs := TFormatSettings.Create(Local); + FormatSetting := TFormatSettings.Create(Local); - Result := StrToDateTime(Date, fs); + Result := StrToDateTime(Date, FormatSetting); end; function TDateTimeHelper.AddDays(const NumberOfDays: Int32 = 1): TDateTime;