Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit 47fcb07

Browse files
committed
Allow date format yyyy-mm-dd
1 parent bb3123c commit 47fcb07

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

DistributionUpdate/PackageUpdate/PackageInfoTools.g

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,34 @@ UpdatePackageInfoFiles := function(pkgdir)
336336
"\n This is not allowed, so the info file will not be changed\n");
337337
has_error := true;
338338
fi;
339-
if IsBound(infon.Date) then
340-
date := infon.Date;
341-
if not IsString(date) and Length(date) = 10 and date{[3,6]} = "//" and
342-
ForAll( date{ [1,2,4,5,7,8,9,10] }, IsDigitChar ) then
343-
Print(" ERROR (", info.PackageName, "): the date ", date,
344-
"should be a string of the form `dd/mm/yyyy'\n" );
345-
has_error := true;
346-
else
347-
date := List( SplitString( date, "/" ), Int);
348-
if not date[1] in [1..31] and
349-
date[2] in [1..12] and
350-
date[3] > 1999 and # GAP 4 appeared in 1999
351-
date[1] > DaysInMonth( date[2], date[3] ) then
339+
if IsBound(info.Date) then
340+
if IsString(infon.date) and Length(infon.Date) = 10 and infon.Date{[3,6]} = "//" and
341+
ForAll( infon.Date{ [1,2,4,5,7,8,9,10] }, IsDigitChar ) then
342+
date := List( SplitString( infon.Date, "/" ), Int); #here date=[dd,mm,yyyy]
343+
#the format dd/mm/yyyy is ambigous and can be confused with mm/dd/yyyy
344+
#if it is clear from the date that the format is mm/dd/yyyy print a message
345+
if date[2] in [13..31] and date[1] in [1..12] then
352346
Print(" ERROR (", info.PackageName, "): the date ", date,
353-
" is invalid\n" );
347+
"should be a string of the form `yyyy-mm-dd` or `dd/mm/yyyy'\n" );
354348
has_error := true;
355349
fi;
350+
elif IsString(infon.Date) and Length(infon.Date) = 10 and infon.Date{[5,8]} = "--" and
351+
ForAll( infon.Date{ [1,2,3,4,6,7,9,10] }, IsDigitChar ) then
352+
date := List( SplitString( infon.Date, "-" ), Int);
353+
date := Permuted(date, (1,3)); #sort such that date=[dd,mm,yyyy]
354+
else
355+
Print(" ERROR (", info.PackageName, "): the date ", date,
356+
"should be a string of the form `yyyy-mm-dd` or `dd/mm/yyyy'\n" );
357+
has_error := true;
358+
fi;
359+
if IsBound(date) and (not
360+
(date[1] in [1..31] and
361+
date[2] in [1..12] and
362+
date[3] > 1999 and # GAP 4 appeared in 1999
363+
date[1] <= DaysInMonth( date[2], date[3] ))) then
364+
Print(" ERROR (", info.PackageName, "): the date ", date,
365+
" is invalid\n" );
366+
has_error := true;
356367
fi;
357368
else
358369
Print(" ERROR (", info.PackageName, "): no date is bound\n" );

0 commit comments

Comments
 (0)