mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-11 10:58:23 +02:00
# revisions: 47618
git-svn-id: branches/fixes_3_2@47726 -
This commit is contained in:
parent
0feee25b1e
commit
78de5aa123
@ -838,6 +838,7 @@ Procedure ZipDateTimeToDateTime(ZD,ZT : Word;out DT : TDateTime);
|
||||
|
||||
Var
|
||||
Y,M,D,H,N,S,MS : Word;
|
||||
aDate,aTime : TDateTime;
|
||||
|
||||
begin
|
||||
MS:=0;
|
||||
@ -847,10 +848,19 @@ begin
|
||||
D:=ZD and 31;
|
||||
M:=(ZD shr 5) and 15;
|
||||
Y:=((ZD shr 9) and 127)+1980;
|
||||
|
||||
// Some corrections
|
||||
if M < 1 then M := 1;
|
||||
if M > 12 then M:=12;
|
||||
if D < 1 then D := 1;
|
||||
DT:=ComposeDateTime(EncodeDate(Y,M,D),EncodeTime(H,N,S,MS));
|
||||
if D>MonthDays[IsLeapYear(Y)][M] then
|
||||
D:=MonthDays[IsLeapYear(Y)][M];
|
||||
// Try to encode the result, fall back on today if it fails
|
||||
if Not TryEncodeDate(Y,M,D,aDate) then
|
||||
aDate:=Date;
|
||||
if not TryEncodeTime(H,N,S,MS,aTime) then
|
||||
aTime:=Time;
|
||||
// Return result
|
||||
DT:=ComposeDateTime(aDate,ATime);
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user