* [NTG-context] playing with dates
@ 2024-12-16 18:05 Pablo Rodriguez via ntg-context
2024-12-16 18:36 ` [NTG-context] " Henning Hraban Ramm
2024-12-16 20:21 ` Wolfgang Schuster
0 siblings, 2 replies; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-16 18:05 UTC (permalink / raw)
To: ConTeXt users; +Cc: Pablo Rodriguez
Dear list,
I would like to be able to design some calendars.
Is there any way to have a command (Lua or ConTeXt) that can increase or
decrease a given date by days (something like \nextday or \previousday).
I have tried \date and \increment or \decrement, as shown in the wiki:
\starttext
Today is \currentdate.
\dorecurse{25}
{\increment\normalday}
Tomorrow will be \currentdate.
\decrement\normalday
%\increment\normalmonth% -- gives an error
\increment\normalyear
And today in a year will be \currentdate.
\stoptext
But the main problem is that I end up having the improbable day of
December 41st, 2024 (with \decrement\normalday, it would read -9th).
Besides, \normalmonth cannot be incremented or decremented (although
this would be useless for me).
Is there any way to get a command that can increment or decrement by
days a given date?
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 18:05 [NTG-context] playing with dates Pablo Rodriguez via ntg-context
@ 2024-12-16 18:36 ` Henning Hraban Ramm
2024-12-16 20:03 ` Pablo Rodriguez via ntg-context
2024-12-16 20:21 ` Wolfgang Schuster
1 sibling, 1 reply; 20+ messages in thread
From: Henning Hraban Ramm @ 2024-12-16 18:36 UTC (permalink / raw)
To: ntg-context
Am 16.12.24 um 19:05 schrieb Pablo Rodriguez via ntg-context:
> I would like to be able to design some calendars.
While this doesn’t answer your question, did you try Willi’s calendar
modules, as outlined in
https://articles.contextgarden.net/journal/2022.html ?
I guess the code also contains date calculations.
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 18:36 ` [NTG-context] " Henning Hraban Ramm
@ 2024-12-16 20:03 ` Pablo Rodriguez via ntg-context
2024-12-16 20:30 ` vm via ntg-context
0 siblings, 1 reply; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-16 20:03 UTC (permalink / raw)
To: ntg-context; +Cc: Pablo Rodriguez
On 12/16/24 19:36, Henning Hraban Ramm wrote:
> Am 16.12.24 um 19:05 schrieb Pablo Rodriguez via ntg-context:
>> I would like to be able to design some calendars.
>
> While this doesn’t answer your question, did you try Willi’s calendar
> modules, as outlined in
> https://articles.contextgarden.net/journal/2022.html ?
> I guess the code also contains date calculations.
Hi Hraban,
it doesn’t fit my needs (which are way different from his pocket diary).
Having a command that increases or days (according to the calendar)
avoids me having to implement the whole logic.
Besides, I think \normalday could be way more useful if it could
increment the whole date, not only the day number.
I must admit that I barely understand how \normalday behaves like any
other counter.
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 18:05 [NTG-context] playing with dates Pablo Rodriguez via ntg-context
2024-12-16 18:36 ` [NTG-context] " Henning Hraban Ramm
@ 2024-12-16 20:21 ` Wolfgang Schuster
2024-12-16 20:34 ` Pablo Rodriguez via ntg-context
1 sibling, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2024-12-16 20:21 UTC (permalink / raw)
To: mailing list for ConTeXt users, Pablo Rodriguez via ntg-context
Cc: Pablo Rodriguez
Pablo Rodriguez via ntg-context schrieb am 16.12.2024 um 19:05:
> Dear list,
>
> I would like to be able to design some calendars.
>
> Is there any way to have a command (Lua or ConTeXt) that can increase or
> decrease a given date by days (something like \nextday or \previousday).
>
> I have tried \date and \increment or \decrement, as shown in the wiki:
>
> \starttext
> Today is \currentdate.
>
> \dorecurse{25}
> {\increment\normalday}
>
> Tomorrow will be \currentdate.
>
> \decrement\normalday
>
> %\increment\normalmonth% -- gives an error
> \increment\normalyear
>
> And today in a year will be \currentdate.
> \stoptext
>
> But the main problem is that I end up having the improbable day of
> December 41st, 2024 (with \decrement\normalday, it would read -9th).
>
> Besides, \normalmonth cannot be incremented or decremented (although
> this would be useless for me).
>
> Is there any way to get a command that can increment or decrement by
> days a given date?
https://www.mail-archive.com/ntg-context@ntg.nl/msg88605.html
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 20:03 ` Pablo Rodriguez via ntg-context
@ 2024-12-16 20:30 ` vm via ntg-context
2024-12-16 21:18 ` Pablo Rodriguez via ntg-context
0 siblings, 1 reply; 20+ messages in thread
From: vm via ntg-context @ 2024-12-16 20:30 UTC (permalink / raw)
To: ntg-context; +Cc: vm
On 16/12/2024 21:03, Pablo Rodriguez via ntg-context wrote:
> Besides, I think \normalday could be way more useful if it could
> increment the whole date, not only the day number.
does this help?
https://www.lua.org/pil/22.1.html
> nn = os.date("*t", os.time{year=2024, month=12+15, day=16+19})
> nn.year, nn.month, nn.day
To produce a date table, we use the format string "*t". For instance,
the following code
temp = os.date("*t", 906000490)
produces the table
{year = 1998, month = 9, day = 16, yday = 259, wday = 4,
hour = 23, min = 48, sec = 10, isdst = false}
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 20:21 ` Wolfgang Schuster
@ 2024-12-16 20:34 ` Pablo Rodriguez via ntg-context
2024-12-16 22:49 ` Aditya Mahajan
0 siblings, 1 reply; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-16 20:34 UTC (permalink / raw)
To: ntg-context; +Cc: Pablo Rodriguez
On 12/16/24 21:21, Wolfgang Schuster wrote:
> Pablo Rodriguez via ntg-context schrieb am 16.12.2024 um 19:05:
>> [...]
>> Is there any way to get a command that can increment or decrement by
>> days a given date?
>
> https://www.mail-archive.com/ntg-context@ntg.nl/msg88605.html
Many thanks for your reply, Wolfgang.
I‘m afraid that approach is too complex for me to implement a full
calendar of previous, current and next year.
I have tried that, but only the required xtable seems too complicated to
me (using xtables).
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 20:30 ` vm via ntg-context
@ 2024-12-16 21:18 ` Pablo Rodriguez via ntg-context
2024-12-16 21:52 ` Wolfgang Schuster
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-16 21:18 UTC (permalink / raw)
To: vm via ntg-context; +Cc: Pablo Rodriguez
On 12/16/24 21:30, vm via ntg-context wrote:
> On 16/12/2024 21:03, Pablo Rodriguez via ntg-context wrote:
>> Besides, I think \normalday could be way more useful if it could
>> increment the whole date, not only the day number.
>
> does this help?
>
> https://www.lua.org/pil/22.1.html
I’m afraid not, because I wonder how to typeset a whole year with that
os.date() and os.time() functions.
I mean, a huge xtable that contains 12 months, with a variable number of
weeks and days each, placing each day number in weeks from Monday to Sunday.
I cannot even get a header with the correct year number (although I know
how to invoke that, I get 2028 instead of 2024 [probably because of
for-loops]).
It seems that it is too complex for me (and I have already invested two
afternoons in this).
For some reason, not meant to be in my case,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 21:18 ` Pablo Rodriguez via ntg-context
@ 2024-12-16 21:52 ` Wolfgang Schuster
2024-12-17 15:28 ` Pablo Rodriguez via ntg-context
2024-12-16 22:17 ` vm via ntg-context
2024-12-17 9:02 ` vm via ntg-context
2 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Schuster @ 2024-12-16 21:52 UTC (permalink / raw)
To: mailing list for ConTeXt users, Pablo Rodriguez via ntg-context
Cc: Pablo Rodriguez
Pablo Rodriguez via ntg-context schrieb am 16.12.2024 um 22:18:
> On 12/16/24 21:30, vm via ntg-context wrote:
>> On 16/12/2024 21:03, Pablo Rodriguez via ntg-context wrote:
>>> Besides, I think \normalday could be way more useful if it could
>>> increment the whole date, not only the day number.
>> does this help?
>>
>> https://www.lua.org/pil/22.1.html
> I’m afraid not, because I wonder how to typeset a whole year with that
> os.date() and os.time() functions.
>
> I mean, a huge xtable that contains 12 months, with a variable number of
> weeks and days each, placing each day number in weeks from Monday to Sunday.
>
> I cannot even get a header with the correct year number (although I know
> how to invoke that, I get 2028 instead of 2024 [probably because of
> for-loops]).
>
> It seems that it is too complex for me (and I have already invested two
> afternoons in this).
>
> For some reason, not meant to be in my case,
Use trialtypesetting in a table when you perform calculations etc.
\starttext
\startxtable
\startxrow
\startxcell
\startmode[*trialtypesetting]
123456789
\stopmode
\startnotmode[*trialtypesetting]
123
%123\rlap{\lightgray 456789}
\stopnotmode
\stopxcell
\stopxrow
\stopxtable
\startxtable
\startxrow
\startxcell
\doifelsemode{*trialtypesetting}
{123456789}
{123}
%{123\rlap{\lightgray 456789}}
\stopxcell
\stopxrow
\stopxtable
\startxtable
\startxrow
\startxcell
\iftrialtypesetting
123456789
\else
123
%123\rlap{\lightgray 456789}
\fi
\stopxcell
\stopxrow
\stopxtable
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 21:18 ` Pablo Rodriguez via ntg-context
2024-12-16 21:52 ` Wolfgang Schuster
@ 2024-12-16 22:17 ` vm via ntg-context
2024-12-17 9:02 ` vm via ntg-context
2 siblings, 0 replies; 20+ messages in thread
From: vm via ntg-context @ 2024-12-16 22:17 UTC (permalink / raw)
To: ntg-context; +Cc: vm
On 16/12/2024 22:18, Pablo Rodriguez via ntg-context wrote:
> It seems that it is too complex for me (and I have already invested two
> afternoons in this).
>
> For some reason, not meant to be in my case,
like everyday for one year
8<---
\startluacode
function userdata.now(dd)
local wdays = {"Sun ", "Mon ", "Tue ", "Wed ", "Thu ", "Fri ", "Sat "}
local z = os.date("*t", os.time())
local nn = os.date("*t", os.time{year=z.year, month=z.month,
day=z.day+dd})
--context(wdays[nn.wday] .. nn.year .. "-" .. nn.month .. "-" .. nn.day)
context(string.format("%s %04d-%02d-%02d ", wdays[nn.wday], nn.year,
nn.month, nn.day))
end
\stopluacode
\starttext
\tt
Today is \ctxlua{userdata.now(0)}
\dorecurse{366}{\ctxlua{userdata.now(\recurselevel)}\\ }
\stoptext
--->8
( i'm not fluent in lua, so there might be a much better way to handle
it ;-)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 20:34 ` Pablo Rodriguez via ntg-context
@ 2024-12-16 22:49 ` Aditya Mahajan
2024-12-17 15:44 ` Pablo Rodriguez via ntg-context
0 siblings, 1 reply; 20+ messages in thread
From: Aditya Mahajan @ 2024-12-16 22:49 UTC (permalink / raw)
To: Pablo Rodriguez via ntg-context; +Cc: Pablo Rodriguez
[-- Attachment #1: Type: text/plain, Size: 624 bytes --]
On Mon, 16 Dec 2024, Pablo Rodriguez via ntg-context wrote:
> I‘m afraid that approach is too complex for me to implement a full
> calendar of previous, current and next year.
tikz has various macros to typeset calendars:
\usemodule[tikz]
\usetikzlibrary[calendar]
\starttext
\starttikzpicture
\calendar[dates=2025-01-01 to 2025-04-last,week list,
month label above centered];
\stoptikzpicture
\stoptext
Also see https://tikz.dev/library-calender and https://texample.net/tikz/examples/feature/calendar-library/ (which, in principle, can be translated to ConTeXt rather easily).
Aditya
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 21:18 ` Pablo Rodriguez via ntg-context
2024-12-16 21:52 ` Wolfgang Schuster
2024-12-16 22:17 ` vm via ntg-context
@ 2024-12-17 9:02 ` vm via ntg-context
2024-12-17 9:11 ` [NTG-context] Re: playing with dates [oneliner] vm via ntg-context
2024-12-17 15:36 ` [NTG-context] Re: playing with dates Pablo Rodriguez via ntg-context
2 siblings, 2 replies; 20+ messages in thread
From: vm via ntg-context @ 2024-12-17 9:02 UTC (permalink / raw)
To: ntg-context; +Cc: vm
On 16/12/2024 22:18, Pablo Rodriguez via ntg-context wrote:
> For some reason, not meant to be in my case,
In your terminal, one line fits all ;-)
T="cal2025.tex" && echo "\\starttext\\startTEXpage\\starttyping" >${T}
&& cal 2025 >>${T} && echo "\\stoptyping\\stopTEXpage\\stoptext" >>${T}
&& context ${T}
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates [oneliner]
2024-12-17 9:02 ` vm via ntg-context
@ 2024-12-17 9:11 ` vm via ntg-context
2024-12-17 15:36 ` [NTG-context] Re: playing with dates Pablo Rodriguez via ntg-context
1 sibling, 0 replies; 20+ messages in thread
From: vm via ntg-context @ 2024-12-17 9:11 UTC (permalink / raw)
To: ntg-context; +Cc: vm
or if you want the days:
Y=2025 && T="ncal${Y}.tex" && echo
"\\setuppapersize[A3]\\starttext\\startTEXpage[offset=5mm]\\starttyping"
>${T} && ncal ${Y} >>${T} && echo "\\stoptyping\\stopTEXpage\\stoptext"
>>${T} && context ${T}
;-)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 21:52 ` Wolfgang Schuster
@ 2024-12-17 15:28 ` Pablo Rodriguez via ntg-context
0 siblings, 0 replies; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-17 15:28 UTC (permalink / raw)
To: ntg-context; +Cc: Pablo Rodriguez
On 12/16/24 22:52, Wolfgang Schuster wrote:
> Pablo Rodriguez via ntg-context schrieb am 16.12.2024 um 22:18:
>> [...]
>> I cannot even get a header with the correct year number (although I know
>> how to invoke that, I get 2028 instead of 2024 [probably because of
>> for-loops]).
>> [...]
> Use trialtypesetting in a table when you perform calculations etc.
Many thanks for the info, Wolfgang.
This is something I need to keep in mind when I get weird results in loops.
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-17 9:02 ` vm via ntg-context
2024-12-17 9:11 ` [NTG-context] Re: playing with dates [oneliner] vm via ntg-context
@ 2024-12-17 15:36 ` Pablo Rodriguez via ntg-context
1 sibling, 0 replies; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-17 15:36 UTC (permalink / raw)
To: vm via ntg-context; +Cc: Pablo Rodriguez
On 12/17/24 10:02, vm via ntg-context wrote:
> On 16/12/2024 22:18, Pablo Rodriguez via ntg-context wrote:
>> For some reason, not meant to be in my case,
>
> In your terminal, one line fits all ;-)
>
> T="cal2025.tex" && echo "\\starttext\\startTEXpage\\starttyping" >${T}
> && cal 2025 >>${T} && echo "\\stoptyping\\stopTEXpage\\stoptext" >>${T}
> && context ${T}
Many thanks for your three suggestions, vm.
They would be a way to start doing it, but fortunately there is a proper
calendar solution.
Many thanks for your help,
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-16 22:49 ` Aditya Mahajan
@ 2024-12-17 15:44 ` Pablo Rodriguez via ntg-context
2024-12-17 16:09 ` Henning Hraban Ramm
2024-12-17 17:58 ` Thomas A. Schmitz
0 siblings, 2 replies; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-17 15:44 UTC (permalink / raw)
To: ConTeXt users; +Cc: Pablo Rodriguez
On 12/16/24 23:49, Aditya Mahajan wrote:
> On Mon, 16 Dec 2024, Pablo Rodriguez via ntg-context wrote:
>> I‘m afraid that approach is too complex for me to implement a full
>> calendar of previous, current and next year.
>
> tikz has various macros to typeset calendars:
> [...]
> Also see https://tikz.dev/library-calender and https://texample.net/
> tikz/examples/feature/calendar-library/ (which, in principle, can be
> translated to ConTeXt rather easily).
Hi Aditya,
many thanks for the reference: this solves all my needs (see below).
It would be great (as per
https://texample.net/tikz/examples/birthday-calendar/) to have automatic
Easter calculation.
I guess Lua code would be easier to write, but I cannot get how each
Easter Sunday may be computed.
Many thanks for your help and excuse my crappy (but functional) code,
Pablo
\unprotect
\permanent\tolerant\protected\def\translate[#1]%
{\getparameters[\??translation][#1]%
\ifcsname\??translation\currentlanguage\endcsname
\lastnamedcs
\orelse\ifcsname\??translation\s!en\endcsname
\lastnamedcs
\else
#1%
\fi}
\protect
\usemodule[tikz]
\usetikzlibrary[calendar]
\setupbodyfont[palatino]
\def\pgfcalendarmonthname#1{%
\translate{\ifcase#1\or Enero\or Febrero\or Marzo\or Abril\or
Mayo\or Junio\or Julio\or Agosto\or Septiembre\or Octubre\or
Noviembre\or Diciembre\fi}%
}
\starttext
\startbuffer
\setupheadertexts[\framed[frame=off, foregroundstyle=\bfd, width=1tw,
align=outer,]{\recursestring}]
\startlayout[standard][align=center]
\startxtable[frame=off]
\ctxlua{document.rcount = 1}
\dorecurse{4}
{\startxrow[toffset=1st]
\dorecurse{3}
{\startxcell
\starttikzpicture
\calendar(mycal)[dates=\recursestring-\cldcontext{document.rcount}-01
to \recursestring-\cldcontext{document.rcount}-last, week list,
month label above left,
month text={\feature[+][smallcaps]\%mt},
]
if (Sunday,
equals=2025-04-20,
equals=2025-04-18,
equals=2025-04-19,
equals=01-01,
equals=01-06,
equals=02-22,
equals=05-01,
equals=07-28,
equals=08-15,
equals=09-9,
equals=09-15,
equals=11-1,
equals=12-6,
equals=12-8,
equals=12-25,
equals=02-22) [font=\bf];
\stoptikzpicture
\stopxcell\ctxlua{document.rcount = document.rcount + 1}
\startxcell[width={\ifnum\recurselevel <3 .04675tw\else 0tw\fi}]
\stopxcell}
\stopxrow}
\stopxtable
\stoplayout
\stopbuffer
\doloopoverlist{2050}
{\getbuffer}
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-17 15:44 ` Pablo Rodriguez via ntg-context
@ 2024-12-17 16:09 ` Henning Hraban Ramm
2024-12-17 21:04 ` Pablo Rodriguez via ntg-context
2024-12-17 17:58 ` Thomas A. Schmitz
1 sibling, 1 reply; 20+ messages in thread
From: Henning Hraban Ramm @ 2024-12-17 16:09 UTC (permalink / raw)
To: ntg-context
Am 17.12.24 um 16:44 schrieb Pablo Rodriguez via ntg-context:
> It would be great (as per
> https://texample.net/tikz/examples/birthday-calendar/) to have automatic
> Easter calculation.
>
> I guess Lua code would be easier to write, but I cannot get how each
> Easter Sunday may be computed.
Hi Pablo, you didn’t follow my suggested links.
While Willi’s “main” module PocketDiary doesn’t fit your needs, the
calculations and examples for other kinds of calendars are all there.
https://modules.contextgarden.net/dl/PocketDiary-V2.zip
https://modules.contextgarden.net/dl/Collection-of-calendars-based-on-PocketDiary-module.zip
https://modules.contextgarden.net/dl/Date-driven-lists.zip
Hraban
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-17 15:44 ` Pablo Rodriguez via ntg-context
2024-12-17 16:09 ` Henning Hraban Ramm
@ 2024-12-17 17:58 ` Thomas A. Schmitz
2024-12-17 21:11 ` Pablo Rodriguez via ntg-context
1 sibling, 1 reply; 20+ messages in thread
From: Thomas A. Schmitz @ 2024-12-17 17:58 UTC (permalink / raw)
To: mailing list for ConTeXt users
> On 17. Dec 2024, at 16:44, Pablo Rodriguez via ntg-context <ntg-context@ntg.nl> wrote:
>
> I guess Lua code would be easier to write, but I cannot get how each
> Easter Sunday may be computed.
Here you go:
a = math.fmod(year,19)
b = math.floor(year / 100)
c = math.fmod(year,100)
d = math.floor(b / 4)
e = math.fmod(b,4)
f = math.floor((b + 8) / 25)
g = math.floor((b - f + 1) / 3)
h = math.fmod((19 * a + b - d - g + 15),30)
i = math.floor(c / 4)
k = math.fmod(c,4)
L = math.fmod((32 + 2 * e + 2 * i - h - k),7)
m = math.floor((a + 11 * h + 22 * L) / 451)
eastersundaymonth = math.floor((h + L - 7 * m + 114) / 31)
eastersunday = math.fmod((h + L - 7 * m + 114),31) + 1
Thomas
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-17 16:09 ` Henning Hraban Ramm
@ 2024-12-17 21:04 ` Pablo Rodriguez via ntg-context
2024-12-23 21:19 ` Willi Egger
0 siblings, 1 reply; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-17 21:04 UTC (permalink / raw)
To: ntg-context; +Cc: Pablo Rodriguez
On 12/17/24 17:09, Henning Hraban Ramm wrote:
> Am 17.12.24 um 16:44 schrieb Pablo Rodriguez via ntg-context:
>> It would be great (as per
>> https://texample.net/tikz/examples/birthday-calendar/) to have automatic
>> Easter calculation.
>>
>> I guess Lua code would be easier to write, but I cannot get how each
>> Easter Sunday may be computed.
>
> Hi Pablo, you didn’t follow my suggested links.
Sorry, Hraban, I followed the only link I got in my message.
What I completetely overlooked was that there were two more articles by
Willi about PocketDiary.
I thought the first article was the module presentation for the new version.
I had mistakenly thought that that first article was all it was about that.
Apologies for my hurried reading (also to Willi),
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-17 17:58 ` Thomas A. Schmitz
@ 2024-12-17 21:11 ` Pablo Rodriguez via ntg-context
0 siblings, 0 replies; 20+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-12-17 21:11 UTC (permalink / raw)
To: ntg-context; +Cc: Pablo Rodriguez
On 12/17/24 18:58, Thomas A. Schmitz wrote:
>> On 17. Dec 2024, at 16:44, Pablo Rodriguez via ntg-context <ntg-context@ntg.nl> wrote:
>> I guess Lua code would be easier to write, but I cannot get how each
>> Easter Sunday may be computed.
>
> Here you go:
Many thanks for your help, Thomas.
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
* [NTG-context] Re: playing with dates
2024-12-17 21:04 ` Pablo Rodriguez via ntg-context
@ 2024-12-23 21:19 ` Willi Egger
0 siblings, 0 replies; 20+ messages in thread
From: Willi Egger @ 2024-12-23 21:19 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi Pablo,
never mind!
Dealing with date calculations is a tedious job. Calculating the easter date as provided by Thomas is a clean way, however I do not know where the algorithm comes from. — What i used in my module is a translation of a BASIC-programme, developed by Ron Mallen, Australia, in 1985. The code represents a direct translation of the formerly used tables for this purpose. Mallen’s method claims to be 100% accurate…
The easter calculation is a function in my module which is only depending on the year, so you could easily pull it out and use it independently from the module.
I hope you will succeed managing your calendars in due time :-)
Kind regards
Willi
> On 17 Dec 2024, at 22:04, Pablo Rodriguez via ntg-context <ntg-context@ntg.nl> wrote:
>
> On 12/17/24 17:09, Henning Hraban Ramm wrote:
>> Am 17.12.24 um 16:44 schrieb Pablo Rodriguez via ntg-context:
>>> It would be great (as per
>>> https://texample.net/tikz/examples/birthday-calendar/) to have automatic
>>> Easter calculation.
>>>
>>> I guess Lua code would be easier to write, but I cannot get how each
>>> Easter Sunday may be computed.
>>
>> Hi Pablo, you didn’t follow my suggested links.
>
> Sorry, Hraban, I followed the only link I got in my message.
>
> What I completetely overlooked was that there were two more articles by
> Willi about PocketDiary.
>
> I thought the first article was the module presentation for the new version.
>
> I had mistakenly thought that that first article was all it was about that.
>
> Apologies for my hurried reading (also to Willi),
>
> Pablo
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-12-23 21:29 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-16 18:05 [NTG-context] playing with dates Pablo Rodriguez via ntg-context
2024-12-16 18:36 ` [NTG-context] " Henning Hraban Ramm
2024-12-16 20:03 ` Pablo Rodriguez via ntg-context
2024-12-16 20:30 ` vm via ntg-context
2024-12-16 21:18 ` Pablo Rodriguez via ntg-context
2024-12-16 21:52 ` Wolfgang Schuster
2024-12-17 15:28 ` Pablo Rodriguez via ntg-context
2024-12-16 22:17 ` vm via ntg-context
2024-12-17 9:02 ` vm via ntg-context
2024-12-17 9:11 ` [NTG-context] Re: playing with dates [oneliner] vm via ntg-context
2024-12-17 15:36 ` [NTG-context] Re: playing with dates Pablo Rodriguez via ntg-context
2024-12-16 20:21 ` Wolfgang Schuster
2024-12-16 20:34 ` Pablo Rodriguez via ntg-context
2024-12-16 22:49 ` Aditya Mahajan
2024-12-17 15:44 ` Pablo Rodriguez via ntg-context
2024-12-17 16:09 ` Henning Hraban Ramm
2024-12-17 21:04 ` Pablo Rodriguez via ntg-context
2024-12-23 21:19 ` Willi Egger
2024-12-17 17:58 ` Thomas A. Schmitz
2024-12-17 21:11 ` Pablo Rodriguez via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).