2011/3/24 Aditya Mahajan <[email protected]>
> \getdate would return os.date("%Y-%m-%d",attr.modification)
>> and
>> \getdate{"long"} would return os.date("%Y-%m-%d
>> %H:%M",attr.modification)
>>
>> I have looked at lua, but do not see how to do it. (Something else to
>> learn.)
>>
> I would like to do something like the following:
>
> Untested:
>
> \def\getdate%
> {\dosinglegroupempty\dogetdate}
>
> \def\dogetdate#1%
> {context{modification_date("\jobname.tex", "#1")}}
>
> and then in the lua code
>
> function modification_date(file, format)
> ....
> if format == "long" then
> ....
> else
> ...
> end
>
> end
>
I have:
\startluacode
function modification_date(file, format)
local f = file
local attr = lfs.attributes(f)
assert (type(attr) == "table")
if attr.mode ~= "directory" then
if format == "long" then
return os.date("%Y-%m-%d %H:%M",attr.modification)
else
return os.date("%Y-%m-%d",attr.modification)
end
end
end
\stopluacode
\def\getdate%
{\dosinglegroupempty\dogetdate}
\def\dogetdate#1%
{context{modification_date("\jobname.tex", "#1")}}
This results in:
contextmodification_date("subversion.tex", "")
--
Cecil Westerhof
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________