From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67343 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:29:16 +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="===============1612889502==" X-Trace: dough.gmane.org 1300984202 16878 80.91.229.12 (24 Mar 2011 16:30:02 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 24 Mar 2011 16:30:02 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Mar 24 17:29:58 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 1Q2nQ6-0001wj-BF for gctc-ntg-context-518@m.gmane.org; Thu, 24 Mar 2011 17:29:58 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 5D77CCAB44; Thu, 24 Mar 2011 17:29:43 +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 XzoQyvhB+Fcv; Thu, 24 Mar 2011 17:29:40 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 4818ACAB36; Thu, 24 Mar 2011 17:29:40 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id DC0EBCAB36 for ; Thu, 24 Mar 2011 17:29:38 +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 z8OAOH6QsHG4 for ; Thu, 24 Mar 2011 17:29:27 +0100 (CET) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id AE68ACAB31 for ; Thu, 24 Mar 2011 17:29:27 +0100 (CET) Original-Received: from mail-ew0-f41.google.com (mail-ew0-f41.google.com [209.85.215.41]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p2OGTfrP032238 for ; Thu, 24 Mar 2011 17:29:41 +0100 Original-Received: by ewy9 with SMTP id 9so149043ewy.14 for ; Thu, 24 Mar 2011 09:29:41 -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=AtSqTxpH65qq5+oxni4r9Xb2kCsitUGCGfP/1WfaO58=; b=rK9OXC5HjXM0QspUMSAHg6NBcs/deLpGIujHBrFCQeS9x97KxvUjMEVgwLsIGVcXct gUrH0yMdEkXNQSj6vcvTG/+yhl1pVCxhgakRKA2KjtN6RXVki1qJ+dNvZz73/NObf5yt KD+Re2QwSxDxJkynrfYmcBrHy9n+LYRI5DlA0= 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=Z8TEHa8AHC+pLaoOwrCqTziI6Oe23jDBvV2orybBPck1Z+IiHjwSi66SUm1NrIcfVn R9N5HQcotLp+tdt6BBknxksWCB0cgeRYhi+HOuKJH8JiICfJVkyVcN/Q6dKxcm3GbmM9 WyKiLCoHHClcgLK6tniCE+83YJlHDlh/ST8ro= Original-Received: by 10.223.16.138 with SMTP id o10mr9811386faa.88.1300984156332; Thu, 24 Mar 2011 09:29:16 -0700 (PDT) Original-Received: by 10.223.110.71 with HTTP; Thu, 24 Mar 2011 09:29:16 -0700 (PDT) In-Reply-To: X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.215.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: 0rEn4tF05 - 1758e157f019 - 20110324 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 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:67343 Archived-At: --===============1612889502== Content-Type: multipart/alternative; boundary=001517475a447f2a86049f3cfa7f --001517475a447f2a86049f3cfa7f Content-Type: text/plain; charset=ISO-8859-1 2011/3/24 Aditya Mahajan > \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 --001517475a447f2a86049f3cfa7f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2011/3/24 Aditya Mahajan <<= a href=3D"mailto:adityam@umich.edu">adityam@umich.edu>
=A0 \getdate would return os.date("%Y-%m-%d",attr.modification)<= br> and
=A0 \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%
=A0{\dosinglegroupempty\dogetdate}

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

and then in the lua code

function modification_date(file, format)
....
if format =3D=3D "long" then
....
else
...
end

end

I have:
\startluacode
=A0 function modif= ication_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 assert (type(attr) = =3D=3D "table")
=A0=A0=A0 if attr.mode ~=3D "directory&qu= ot; then
=A0=A0=A0=A0=A0 if format =3D=3D "long" then
=A0=A0=A0=A0=A0= =A0=A0 return os.date("%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&qu= ot;,attr.modification)
=A0=A0=A0=A0=A0 end
=A0=A0=A0 end
=A0 end \stopluacode

\def\getdate%
=A0{\dosinglegroupempty\dogetdate}
=
\def\dogetdate#1%
=A0 {context{modification_date("\jobname.tex&= quot;, "#1")}}

This results in:
=A0 =A0 contextmodifica= tion_date("subversion.tex", "")

--
Cecil Westerhof
--001517475a447f2a86049f3cfa7f-- --===============1612889502== 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 ___________________________________________________________________________________ --===============1612889502==--