From 78de5aa1230fb7dc0c2a7472e2600743779fdfe9 Mon Sep 17 00:00:00 2001 From: marco Date: Tue, 8 Dec 2020 20:34:09 +0000 Subject: [PATCH] # revisions: 47618 git-svn-id: branches/fixes_3_2@47726 - --- packages/paszlib/src/zipper.pp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/paszlib/src/zipper.pp b/packages/paszlib/src/zipper.pp index 70f1ad32f8..238e8167e6 100644 --- a/packages/paszlib/src/zipper.pp +++ b/packages/paszlib/src/zipper.pp @@ -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;