From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67351 Path: news.gmane.org!not-for-mail From: Cecil Westerhof Newsgroups: gmane.comp.tex.context Subject: Re: Use date of the tex file in the document Date: Thu, 24 Mar 2011 18:42:12 +0100 Message-ID: References: <20110324102202.GD3626@orcus> <20110324120017.78d5e9b9@glyph> <579A9EA3-A9B1-44A6-ABC8-36F733161523@googlemail.com> <20110324172929.GA4137@orcus.urz.uni-heidelberg.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1957107783==" X-Trace: dough.gmane.org 1300988715 14607 80.91.229.12 (24 Mar 2011 17:45:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 24 Mar 2011 17:45:15 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Mar 24 18:45:10 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q2oas-0006FB-Lc for gctc-ntg-context-518@m.gmane.org; Thu, 24 Mar 2011 18:45:10 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 769D4CAB49; Thu, 24 Mar 2011 18:44:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id H5eSFsmgR4ul; Thu, 24 Mar 2011 18:44:52 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 097C4CAB36; Thu, 24 Mar 2011 18:44:52 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id B63A3CAB36 for ; Thu, 24 Mar 2011 18:44:50 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PHEyqJGt5HHI for ; Thu, 24 Mar 2011 18:44:48 +0100 (CET) Original-Received: from filter4-nij.mf.surf.net (filter4-nij.mf.surf.net [195.169.124.155]) by balder.ntg.nl (Postfix) with ESMTP id B25FBCAB31 for ; Thu, 24 Mar 2011 18:44:48 +0100 (CET) Original-Received: from mail-fx0-f41.google.com (mail-fx0-f41.google.com [209.85.161.41]) by filter4-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p2OHj2QC025128 for ; Thu, 24 Mar 2011 18:45:02 +0100 Original-Received: by fxm18 with SMTP id 18so328430fxm.14 for ; Thu, 24 Mar 2011 10:45:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=jj710yG4T8OArESJ43POa4w7Jt4KTD0DbALsur5C1Xs=; b=aWe3+F1Oa9zKiYgnYXsQLgVw2gUXe3lo+KmSehTrbF4anSK/sqCgwbhfAYXlR8ITZw nxkUBkzcBo/+UP7+rdA9n4D/nUui0BxOd6AXJHf1W3fKaCG8pwlgT+IkyxJmum913DBx Wo9k3yOgcl6AZQIiDCpxQvuQP70huiXbIRby4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=dJtH7a2sEgoH9Gwd/sj1k8kDmaAah45CYZkVAZvQmgMpNPGoFqMG0QtOS6+GehQELd DC0tefO19bkdhCuiNB6hA2e1OyOumkDFq82ugQ7NLxH0C+5+bygMsStdXxJxHNMVMKE/ YS1Agvn/v9MEg7Gwbtwk6D7zmCcVLZ+yYHdTQ= Original-Received: by 10.223.159.9 with SMTP id h9mr1490075fax.145.1300988532983; Thu, 24 Mar 2011 10:42:12 -0700 (PDT) Original-Received: by 10.223.110.71 with HTTP; Thu, 24 Mar 2011 10:42:12 -0700 (PDT) In-Reply-To: <20110324172929.GA4137@orcus.urz.uni-heidelberg.de> X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.161.41; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 04En5J2iw - 9c01c6d77733 - 20110324 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.155 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:67351 Archived-At: --===============1957107783== Content-Type: multipart/alternative; boundary=0023541868d45d87b9049f3dff63 --0023541868d45d87b9049f3dff63 Content-Type: text/plain; charset=ISO-8859-1 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"} \stoptext This gives: 2011-03-24 2011-03-24"short" 2011-03-24"long" -- Cecil Westerhof --0023541868d45d87b9049f3dff63 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2011/3/24 Philipp Gesang <<= a href=3D"mailto:pgesang@ix.urz.uni-heidelberg.de">pgesang@ix.urz.uni-heide= lberg.de>
> =A0 =A0 =A0{\ctalua{context(modification_date("\jobname.tex"= , "#1"))}}
=A0 =A0 =A0 =A0 =A0 ^
s/\\ctalua/\\ctxlua/

I have:
\startluacode
= =A0 function modification_date(file, format)
=A0=A0=A0 local f=A0=A0=A0 = =3D file
=A0=A0=A0 local attr =3D lfs.attributes(f)

=A0=A0=A0 ass= ert (type(attr) =3D=3D "table")
=A0=A0=A0 if attr.mode ~=3D "directory" then
=A0=A0=A0=A0=A0 i= f format =3D=3D "long" then
=A0=A0=A0=A0=A0=A0=A0 return os.da= te("%Y-%m-%d %H:%M",attr.modification)
=A0=A0=A0=A0=A0 else=A0=A0=A0=A0=A0=A0=A0 return os.date("%Y-%m-%d",attr.modificatio= n)
=A0=A0=A0=A0=A0 end
=A0=A0=A0 end
=A0 end
\stopluacode

\def= \getdate
=A0{\dosingleempty\dogetdate}

\def\dogetdate[#1]%
=A0= {\ctxlua{context(modification_date("\jobname.tex", "#1"= ))}}

\starttext

\getdate

\getdate{"short"}

\getdate{"long&= quot;}

\stoptext

This gives:
2011-03-24
2011-03-24"= ;short"
2011-03-24"long"

--
Cecil= Westerhof
--0023541868d45d87b9049f3dff63-- --===============1957107783== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============1957107783==--