mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 04:39:34 +02:00
+ support leap seconds in TryEncodeTime, resolves #40121
This commit is contained in:
parent
9db751daff
commit
a9f9996dc8
@ -119,7 +119,9 @@ end;
|
||||
function TryEncodeTime(Hour, Min, Sec, MSec:word; Out Time : TDateTime) : boolean;
|
||||
|
||||
begin
|
||||
Result:=(Hour<24) and (Min<60) and (Sec<60) and (MSec<1000);
|
||||
Result:=((Hour<24) and (Min<60) and (Sec<60) and (MSec<1000)) or
|
||||
{ allow leap second }
|
||||
((Hour=23) and (Min=59) and (Sec=60) and (MSec<1000));
|
||||
If Result then
|
||||
Time:=TDateTime(cardinal(Hour)*3600000+cardinal(Min)*60000+cardinal(Sec)*1000+MSec)/MSecsPerDay;
|
||||
end;
|
||||
|
10
tests/webtbs/tw40121.pp
Normal file
10
tests/webtbs/tw40121.pp
Normal file
@ -0,0 +1,10 @@
|
||||
uses
|
||||
dateutils;
|
||||
var
|
||||
dt : TDateTime;
|
||||
begin
|
||||
if not(TryISOStrToDateTime('2015-06-30T23:59:60Z',dt)) then
|
||||
halt(1);
|
||||
if not(TryISOStrToDateTime('2016-12-31T23:59:60Z',dt)) then
|
||||
halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user