From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/32376 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: Week number Date: Sat, 30 Dec 2006 15:00:24 +0100 Message-ID: <459670F8.5020106@elvenkind.com> References: <45941026$0$4168$ba624c82@nntp02.dk.telia.net> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1167487257 31991 80.91.229.12 (30 Dec 2006 14:00:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 30 Dec 2006 14:00:57 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sat Dec 30 15:00:55 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1H0elb-0007is-RY for gctc-ntg-context-518@m.gmane.org; Sat, 30 Dec 2006 15:00:55 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 68BC620018; Sat, 30 Dec 2006 14:58:34 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 23358-03; Sat, 30 Dec 2006 14:58:24 +0100 (CET) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 8011620002; Sat, 30 Dec 2006 14:58:24 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C8D7120005 for ; Sat, 30 Dec 2006 14:58:20 +0100 (CET) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 23913-05 for ; Sat, 30 Dec 2006 14:58:13 +0100 (CET) Original-Received: from post-24.mail.nl.demon.net (post-24.mail.nl.demon.net [194.159.73.194]) by ronja.ntg.nl (Postfix) with SMTP id 3D78620001 for ; Sat, 30 Dec 2006 14:58:12 +0100 (CET) Original-Received: from boo.demon.nl ([82.161.175.147]:43857 helo=[10.10.0.3]) by post-24.mail.nl.demon.net with esmtp (Exim 4.51) id 1H0el7-000Jy3-BS for ntg-context@ntg.nl; Sat, 30 Dec 2006 14:00:25 +0000 User-Agent: Mozilla Thunderbird 1.0.6-7.6.20060mdk (X11/20050322) X-Accept-Language: en-us, en Original-To: mailing list for ConTeXt users In-Reply-To: <45941026$0$4168$ba624c82@nntp02.dk.telia.net> X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 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 X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:32376 Archived-At: Hi all, I just posted this (the result of a rainy morning in Dordrecht, NL) to comp.text.tex. Someone here might be interested as well. Best, Taco ------------- Mads Munch Hansen wrote: > Hi all, and merry Christmas :) > > Is there a way to have LaTeX print the current week number, like the > \date command? I was feeling a bit bored today, so I came up with this. It is a plain e-TeX input file instead of a LaTeX package, but it should run without problems. Watch out: Dec 29 can be week 1 of the next year; and Jan 3 can be week 53 of the previous year. Best wishes, Taco %% calendarweek.tex %% 2006 (C) Taco Hoekwater, public domain %% %% Usage: %% \calendarweek{30}{12}{2006} %% \def\Expr#1{\the\numexpr #1\relax} \def\Modulonumber#1#2{\Expr{#2-((((#2+(#1/2))/#1)-1)*#1)}} \def\Divisionnumber#1#2{\Expr{(2*#2-#1)/(2*#1)}} \def\Mod#1#2{\Modulonumber{\Expr{#2}}{\Expr{#1}}} \def\Div#1#2{\Divisionnumber{\Expr{#2}}{\Expr{#1}}} \def\Jday#1#2#3% {\Expr{#1+\Div{((153*(\Expr{#2+(12*(\Div{14-#2}{12}))-3}))+2)} {5}+365*(\Expr{#3+4800-(\Div{14-#2}{12})})+ (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{4})- (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{100})+ (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{400})-32045 }} \def\cwhlp#1#2#3% {\Expr{\Mod {\Mod {\Mod {\Expr {\Jday{#1}{#2}{#3}+31741-\Mod{\Jday{#1}{#2}{#3}}{7}}}% {146097}}{36524}}{1461}}} \def\calendarweek#1#2#3% {\Expr{\Expr{\Div{\Expr{\Mod{\cwhlp{#1}{#2}{#3}- \Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}{365}+ \Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}}{7} +1}}} \endinput