From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67341 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 17:09:21 +0100 Message-ID: References: <20110324102202.GD3626@orcus> <20110324120017.78d5e9b9@glyph> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0839619065==" X-Trace: dough.gmane.org 1300982986 8894 80.91.229.12 (24 Mar 2011 16:09:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 24 Mar 2011 16:09:46 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Mar 24 17:09:42 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 1Q2n6T-000678-GE for gctc-ntg-context-518@m.gmane.org; Thu, 24 Mar 2011 17:09:41 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 76D08CAB54; Thu, 24 Mar 2011 17:09:26 +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 nQ92-nyuTHtJ; Thu, 24 Mar 2011 17:09:22 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id EDD0ACAB31; Thu, 24 Mar 2011 17:09:21 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A622CCAB31 for ; Thu, 24 Mar 2011 17:09:20 +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 QHXcWJ2uzGKR for ; Thu, 24 Mar 2011 17:09:18 +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 A1352CAAFF for ; Thu, 24 Mar 2011 17:09:18 +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 p2OG9WSU031302 for ; Thu, 24 Mar 2011 17:09:32 +0100 Original-Received: by fxm18 with SMTP id 18so227178fxm.14 for ; Thu, 24 Mar 2011 09:09:32 -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=MP5cNMawvlVq7rDIytEU8y/N/F6kujeJAAERDuKeQWM=; b=ArPRE0RyJqMWFgYD0rQ5HE4HFMjw42YrWE8wFbCQgr3KbBvRhRTRvjtgAMQNpBWMS7 L7q+v9V/S41VzkUfSVt8rJN8UG8BINC058qq63h8n+lY5pEqydCFZqxlSKg12GuHQ1vp 2JNJ8FoM7t1AgFfQ6pcnRUs4j8iBGTYueuUzM= 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=l3mFZQ9pJq2qCawrGm0uYBCF0l++3B44kLRlJL4UNGr6MUhcLfcO+gHH8RBW8s9+5P jL1yzOxQQt0g85h9QjvRkcbMyi7M4M1e1SLtY4MmaMCsI7wxA4dqp0j/CXrqzZmYhm+5 +l1OOH1sjyXzBbkcl15K4J1wDDmdYcnrDNB5w= Original-Received: by 10.223.16.138 with SMTP id o10mr9787092faa.88.1300982961781; Thu, 24 Mar 2011 09:09:21 -0700 (PDT) Original-Received: by 10.223.110.71 with HTTP; Thu, 24 Mar 2011 09:09:21 -0700 (PDT) In-Reply-To: <20110324120017.78d5e9b9@glyph> 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: 04En49wmO - 753bdfd1ada1 - 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:67341 Archived-At: --===============0839619065== Content-Type: multipart/alternative; boundary=001517475a444bbbda049f3cb356 --001517475a444bbbda049f3cb356 Content-Type: text/plain; charset=ISO-8859-1 2011/3/24 Marco > On 2011-03-24 Philipp Gesang 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 --001517475a444bbbda049f3cb356 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2011/3/24 Marco <netuse@lavabit.com>
On 2011-03-24 Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> wrote:

This should also work:

\starttext

\startluacode
=A0function modification_date (file)
=A0 =A0local f =3D file
=A0 =A0local attr =3D lfs.attributes (f)
=A0 =A0assert (type(attr) =3D=3D "table")
=A0 =A0if attr.mode ~=3D "directory" then
=A0 =A0 =A0return os.date("%Y-%m-%d %H:%M",attr.modification) =A0 =A0end
=A0end
\stopluacode

\unexpanded\def\getdate{%
=A0\ctxlua{context(modification_date ("\jobname.tex"))}%
}

\getdate

\stoptext

I would like to do somethi= ng like the following:
=A0=A0=A0 \getdate would return os.date("%Y-= %m-%d",attr.modification)
and
=A0=A0=A0 \getdate{"= long"} would return os.date("%Y-%m-%d %H:%M",attr.modificati= on)

I have looked at lua, but do not see how to do it. (Something else to l= earn.)

--
Cecil Westerhof
--001517475a444bbbda049f3cb356-- --===============0839619065== 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 ___________________________________________________________________________________ --===============0839619065==--