[NTG-context] Use date of the tex file in the document

Cecil Westerhof cldwesterhof at gmail.com
Thu Mar 24 17:09:21 CET 2011


2011/3/24 Marco <netuse at lavabit.com>

> On 2011-03-24 Philipp Gesang <pgesang at ix.urz.uni-heidelberg.de> wrote:
>
> This should also work:
>
> \starttext
>
> \startluacode
>  function modification_date (file)
>    local f = file
>    local attr = lfs.attributes (f)
>    assert (type(attr) == "table")
>    if attr.mode ~= "directory" then
>      return os.date("%Y-%m-%d %H:%M",attr.modification)
>    end
>  end
> \stopluacode
>
> \unexpanded\def\getdate{%
>  \ctxlua{context(modification_date ("\jobname.tex"))}%
> }
>
> \getdate
>
> \stoptext
>

I would like to do something like the following:
    \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.)

-- 
Cecil Westerhof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20110324/ca995635/attachment-0001.html>


More information about the ntg-context mailing list