Skip to content

Commit

Permalink
Use NameMonth
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jun 27, 2024
1 parent e5fcb1f commit 65b46cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 3 additions & 5 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2684,7 +2684,7 @@ Unicode:= "dummy";
Encode:= "dummy";

InstallGlobalFunction( BibEntry, function( arg )
local key, pkgname, pkginfo, GAP, ps, months, val, entry, author;
local key, pkgname, pkginfo, GAP, ps, val, entry, author;

key:= false;
if Length( arg ) = 1 and IsString( arg[1] ) then
Expand Down Expand Up @@ -2778,13 +2778,11 @@ InstallGlobalFunction( BibEntry, function( arg )
# We put the version information into the <C>title</C> component since
# the <C>edition</C> component is not supported in the base styles.

months:= [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
if GAP then
val:= SplitString( GAPInfo.Date, "-" );
if Length( val ) = 3 then
if Int( val[2] ) in [ 1 .. 12 ] then
val:= Concatenation( " <month>", months[ Int( val[2] ) ],
val:= Concatenation( " <month>", NameMonth[ Int( val[2] ) ],
"</month>\n <year>", val[1], "</year>\n" );
else
val:= Concatenation( " <month>", val[2],
Expand Down Expand Up @@ -2838,7 +2836,7 @@ InstallGlobalFunction( BibEntry, function( arg )
and Length( pkginfo.Date ) = 10 then
if Int( pkginfo.Date{ [ 4, 5 ] } ) in [ 1 .. 12 ] then
Append( entry, Concatenation(
" <month>", months[ Int( pkginfo.Date{ [ 4, 5 ] } ) ],
" <month>", NameMonth[ Int( pkginfo.Date{ [ 4, 5 ] } ) ],
"</month>\n",
" <year>", pkginfo.Date{ [ 7 .. 10 ] }, "</year>\n" ) );
else
Expand Down
6 changes: 2 additions & 4 deletions tst/testinstall/package.tst
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,15 @@ new methods:

# Cite() expects GAPInfo.Date to be of the form "YYYY-MM-DD" or "YYYY-Mon-DD" (or "today")
gap> IsDateFormatValid := function( datestring )
> local months, val;
> local val;
> if datestring = "today" then
> return true;
> fi;
> val:= SplitString( datestring, "-" );
> if Length( val ) <> 3 then
> return false;
> fi;
> months:= [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
> "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
> return Int( val[1] ) in [ 1900 .. 2100 ] and ( val[2] in months or Int( val[2] ) in [ 1 .. 12 ] ) and Int( val[3] ) in [ 1 .. 31 ];
> return Int( val[1] ) in [ 1900 .. 2100 ] and ( val[2] in NameMonth or Int( val[2] ) in [ 1 .. 12 ] ) and Int( val[3] ) in [ 1 .. 31 ];
> end;;
gap> IsDateFormatValid( GAPInfo.Date );
true
Expand Down

0 comments on commit 65b46cf

Please sign in to comment.