Re: [NTG-context] Week number
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 ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Week number
On Sat, 30 Dec 2006, Taco Hoekwater wrote: 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. [...] 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. If you are still bored, how about adding this to ConTeXt, so that one can say Today is \currentdate[weekday] of the \currentdate[week] week of \currentday[year] I do not know if someone will find it useful or not, but it seems like a nice feature to have :) Aditya ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Re: [NTG-context] Week number
Aditya Mahajan wrote: On Sat, 30 Dec 2006, Taco Hoekwater wrote: 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. [...] 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. If you are still bored, how about adding this to ConTeXt, so that one can say Today is \currentdate[weekday] of the \currentdate[week] week of \currentday[year] I do not know if someone will find it useful or not, but it seems like a nice feature to have :) see core-con.tex, such things have been there for years now -) (not sure if it does the same as what taco code does) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context