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

Commit 6bcf1b2

Browse files
committed
Allow date format yyyy-mm-dd
1 parent bb3123c commit 6bcf1b2

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

DistributionUpdate/PackageUpdate/PackageInfoTools.g

+38-15
Original file line numberDiff line numberDiff line change
@@ -336,23 +336,46 @@ 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
352-
Print(" ERROR (", info.PackageName, "): the date ", date,
353-
" is invalid\n" );
339+
if IsBound( infon.Date ) then
340+
if IsString( infon.date ) and Length( infon.Date ) = 10
341+
and infon.Date{ [3,6] } = "//"
342+
and ForAll( infon.Date{ [1,2,4,5,7,8,9,10] }, IsDigitChar ) then
343+
date := List( SplitString( infon.Date, "/" ), Int ); # here date=[dd,mm,yyyy]
344+
# the format dd/mm/yyyy is ambigous and can be confused with mm/dd/yyyy
345+
# if it is clear from the date that the format is mm/dd/yyyy
346+
# print a message
347+
if date[2] in [13..31] and date[1] in [1..12] then
348+
Print(" ERROR (", info.PackageName, "): the date ", infon.Date,
349+
Concatenation("should be a string of the form `yyyy-mm-dd`",
350+
"or `dd/mm/yyyy' representing a date since 1999\n" );
354351
has_error := true;
352+
Unbind( date );
353+
# so that we can check wheter an error was found by checking if
354+
# date is bound
355355
fi;
356+
elif IsString( infon.Date ) and Length( infon.Date ) = 10
357+
and infon.Date{ [5,8] } = "--"
358+
and ForAll( infon.Date{ [1,2,3,4,6,7,9,10] }, IsDigitChar ) then
359+
date := List( SplitString( infon.Date, "-" ), Int);
360+
date := date{ [3,2,1] }; # sort such that date=[dd,mm,yyyy]
361+
else
362+
Print(" ERROR (", info.PackageName, "): the date ", infon.Date,
363+
Concatenation("should be a string of the form `yyyy-mm-dd`",
364+
"or `dd/mm/yyyy' representing a date since 1999\n" );
365+
has_error := true;
366+
Unbind( date );
367+
# so that we can check wheter an error was found by checking if
368+
# date is bound
369+
fi;
370+
if IsBound( date ) and ( not
371+
( date[2] in [1..12] and
372+
date[3] > 1999 and # GAP 4 appeared in 1999
373+
date[1] in [ 1..DaysInMonth( date[2], date[3] ) ] ) ) then
374+
Print(" ERROR (", info.PackageName, "): the date ", infon.Date,
375+
Concatenation( "should be a string of the form",
376+
"`yyyy-mm-dd` or `dd/mm/yyyy' representing a date",
377+
" since 1999\n", ) );
378+
has_error := true;
356379
fi;
357380
else
358381
Print(" ERROR (", info.PackageName, "): no date is bound\n" );

0 commit comments

Comments
 (0)