@@ -234,13 +234,33 @@ BindGlobal("AUTODOC_months", MakeImmutable([
234234# The input can be one of the following:
235235# - AUTODOC_FormatDate(rec), where <rec> is a record with entries year, month, day;
236236# - AUTODOC_FormatDate(year[, month[, day]])
237+ # - AUTODOC_FormatDate(date_str) where date_str is a string of the form "DD/MM/YYYY" or "YYYY-MM-DD"
237238# In each case, the year, month or day may be given as either an
238239# integer, or as a string representing an integer.
239240InstallGlobalFunction( AUTODOC_FormatDate,
240241function (arg )
241242 local date, key, val, result;
242243 if Length(arg) = 1 and IsRecord(arg[ 1 ] ) then
243244 date := ShallowCopy(arg[ 1 ] );
245+ elif Length(arg) = 1 and IsString(arg[ 1 ] ) then
246+ if Length(arg[ 1 ] ) = 10 then
247+ date := arg[ 1 ] ;
248+ if date{[ 3 ,6 ]} = " //" then
249+ date := rec (
250+ day := Int(date{[ 1 ,2 ]} ),
251+ month := Int(date{[ 4 ,5 ]} ),
252+ year := Int(date{[ 7 .. 10 ]} ),
253+ );
254+ elif date{[ 5 ,8 ]} = " --" then
255+ date := rec (
256+ year := Int(date{[ 1 .. 4 ]} ),
257+ month := Int(date{[ 6 ,7 ]} ),
258+ day := Int(date{[ 9 ,10 ]} ),
259+ );
260+ else
261+ Unbind (date);
262+ fi ;
263+ fi ;
244264 elif Length(arg) in [ 1 .. 3 ] then
245265 date := rec ();
246266 date.year := arg[ 1 ] ;
0 commit comments