On 2011-03-24 <18:42:12>, Cecil Westerhof wrote:
2011/3/24 Philipp Gesang
{\ctalua{context(modification_date("\jobname.tex", "#1"))}}
^ s/\\ctalua/\\ctxlua/
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 {\dosingleempty\dogetdate}
\def\dogetdate[#1]% {\ctxlua{context(modification_date("\jobname.tex", "#1"))}}
\starttext
\getdate
\getdate{"short"}
\getdate[long] \getdate[nil] \getdate[false] In context optional args are specified in brackets. It’s all documented on the wiki: http://wiki.contextgarden.net/Commands_with_optional_arguments Regards, phg
\getdate{"long"}
\stoptext
This gives: 2011-03-24 2011-03-24"short" 2011-03-24"long"
-- Cecil Westerhof
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / 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 ___________________________________________________________________________________