From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/67367 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: Use date of the tex file in the document Date: Fri, 25 Mar 2011 01:33:15 +0100 Message-ID: <20110325003315.GA9720@aides> References: <20110324120017.78d5e9b9@glyph> <579A9EA3-A9B1-44A6-ABC8-36F733161523@googlemail.com> <20110324172929.GA4137@orcus.urz.uni-heidelberg.de> <4D8BD420.1090007@wxs.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1393020833==" X-Trace: dough.gmane.org 1301013313 25180 80.91.229.12 (25 Mar 2011 00:35:13 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Mar 2011 00:35:13 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Mar 25 01:35:08 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 1Q2uzZ-00058v-Hz for gctc-ntg-context-518@m.gmane.org; Fri, 25 Mar 2011 01:35:05 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 9B32BCAB1A; Fri, 25 Mar 2011 01:34:49 +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 BotXzTayuEZ3; Fri, 25 Mar 2011 01:34:47 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 0B636CAB4A; Fri, 25 Mar 2011 01:34:47 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id C7AF4CAB4A for ; Fri, 25 Mar 2011 01:34:45 +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 pig4EMWboIna for ; Fri, 25 Mar 2011 01:34:43 +0100 (CET) Original-Received: from filter1-ams.mf.surf.net (filter1-ams.mf.surf.net [192.87.102.69]) by balder.ntg.nl (Postfix) with ESMTP id 482E2CAB1A for ; Fri, 25 Mar 2011 01:34:43 +0100 (CET) Original-Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by filter1-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p2P0Yv5R000658 for ; Fri, 25 Mar 2011 01:34:57 +0100 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p2P0Yt8U003037 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Mar 2011 01:34:56 +0100 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p2P0YtGZ006559 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 25 Mar 2011 01:34:55 +0100 Original-Received: from localhost (dslb-188-104-153-096.pools.arcor-ip.net [188.104.153.96]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id p2P0XHgx007034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Fri, 25 Mar 2011 01:34:54 +0100 In-Reply-To: <4D8BD420.1090007@wxs.nl> X-Operating-System: Linux aides 2.6.38-ARCH X-Polite-Request: "Please try to be nice, don't send html mail." User-Agent: Mutt/1.5.20 (2009-06-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.100.212; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 06EncyVey - 4a9e217170d4 - 20110325 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.69 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:67367 Archived-At: --===============1393020833== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IpbVkmxF4tDyP/Kb" Content-Disposition: inline --IpbVkmxF4tDyP/Kb Content-Type: multipart/mixed; boundary="QKdGvSO+nmPlgiQ/" Content-Disposition: inline --QKdGvSO+nmPlgiQ/ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2011-03-25 <00:30:40>, Hans Hagen wrote: > On 25-3-2011 12:08, Cecil Westerhof wrote: >=20 > >I made the code a little better: > >\startluacode > > os.setlocale("nl_NL") >=20 > blocked in mkiv to prevent unwanted side effects and that will stay Still, one can access context=E2=80=99s language substitution tables to achieve a quasilocale effect (concerning the month, that is). (-> attachments.) Good night all, Philipp >=20 > > function modification_date(file, format) > > local f =3D file > > local attr =3D lfs.attributes(f) >=20 > why the f? >=20 > function modification_date(filename,format) > local attr =3D lfs.attributes(filename) > if type(attr) =3D=3D "table" and attr.mode ~=3D "directory" then > if format =3D=3D "nice" then > return os.date("%Y-%m-%dT%X",attr.modification) .. > os.timezone(true) > elseif format =3D=3D "long" then > return os.date("%d %B %Y %H:%M",attr.modification) > else > return os.date("%d %B %Y",attr.modification) > end > end > return "" > end >=20 >=20 > print(modification_date("oeps.lua","nice")) > print(modification_date("oeps.lua","long")) >=20 > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com > | www.pragma-pod.nl > ----------------------------------------------------------------- > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to= the Wiki! >=20 > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ --=20 () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments --QKdGvSO+nmPlgiQ/ Content-Type: text/x-tex; charset=us-ascii Content-Disposition: attachment; filename="somefile.tex" Content-Transfer-Encoding: quoted-printable \ctxloadluafile{getdate} \def\getdate {\dosingleempty\dogetdate} \def\dogetdate[#1]% {\ctxlua{context(documentdata.modification_date("\jobname.tex", "#1"))}} \def\Testall{% \starttabulate[|r|l|] \NC nice \NC {\os\getdate[nice]} \AR \NC long \NC {\os\getdate[long]} \AR \NC plain \NC {\os\getdate} \AR =20 \stoptabulate \hairline% } \starttext \Testall \language[de] \Testall \language[nl] \Testall \language[it] \Testall \language[no] \Testall \stoptext --QKdGvSO+nmPlgiQ/ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="getdate.lua" #!/usr/bin/env texlua local ldl_texts = languages.data.labels.texts local u = utf local function localize_it (str, lang) local current_language = lang or languages.current(tex.language) return ldl_texts[u.lower(str)].labels[current_language] end local function modification_date (filename, format) local attr = lfs.attributes(filename) if type(attr) == "table" and attr.mode ~= "directory" then if format == "nice" then return os.date("%Y-%m-%dT%X",attr.modification) .. os.timezone(true) elseif format == "long" then local tmp = string.explode(os.date("%d %B %Y %H:%M",attr.modification), " ") local day, month, year, time = table.unpack(tmp) return day .. ". " .. localize_it(month) .. " " .. year .. " " .. time else local tmp = string.explode(os.date("%d %B %Y",attr.modification), " ") local day, month, year = table.unpack(tmp) return day .. ". " .. localize_it(month) .. " " .. year end end return "" end documentdata.modification_date = modification_date --QKdGvSO+nmPlgiQ/-- --IpbVkmxF4tDyP/Kb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk2L4ssACgkQ02lYlJYWs9I3WgCfS6n8vQTlMdBKg9wTeStFFbta jhIAnjo0YLhYpbtkHWxm3PMWmelLB1eX =hrS2 -----END PGP SIGNATURE----- --IpbVkmxF4tDyP/Kb-- --===============1393020833== 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 ___________________________________________________________________________________ --===============1393020833==--