diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgf/utilities/pgfcalendar.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgf/utilities/pgfcalendar.code.tex | 141 |
1 files changed, 112 insertions, 29 deletions
diff --git a/Master/texmf-dist/tex/generic/pgf/utilities/pgfcalendar.code.tex b/Master/texmf-dist/tex/generic/pgf/utilities/pgfcalendar.code.tex index 1e4960066ed..89ee8963e92 100644 --- a/Master/texmf-dist/tex/generic/pgf/utilities/pgfcalendar.code.tex +++ b/Master/texmf-dist/tex/generic/pgf/utilities/pgfcalendar.code.tex @@ -9,6 +9,7 @@ \ProvidesFileRCS{pgfcalendar.code.tex} +\input pgfint.code.tex % Translation stuff @@ -45,18 +46,18 @@ % is executed. When the code is called, lots of information about the % current date (like its day of week) is available. The job of % #4 is to render the date. Typically, this is done by placing nodes -% somewhere, but the function could do other things as well. +% somewhere, but the function could do other things as well. % It is also the job of #4 to position the calendar correctly. % % The different calls of #4 are not surrounded by TeX groups (though % you can do so yourself, of course). This means that settings can % accumulate between different calls, which is often desirable and -% useful. +% useful. % % Inside #4 code, different macros can be access: % % \pgfcalendarprefix -% The parameter #1. This prefix is recomended for nodes inside the +% The parameter #1. This prefix is recommended for nodes inside the % calendar, but you have to use it yourself explicitly. % % \pgfcalendarbeginiso @@ -81,10 +82,10 @@ % Year of day to be checked % % \pgfcalendarcurrentmonth -% Month of day to be chjeck +% Month of day to be checked % % \pgfcalendarcurrentday -% Day of monath of day to be checked +% Day of month of day to be checked % % % Inside the \pgfcalendar macro the macro \ifdate is available, which @@ -105,7 +106,7 @@ \begingroup% % Setup local \ifdate \let\ifdate=\pgfcalendar@local@ifdate% - % Let's start with computing start and end dates... + % Let's start with computing start and end dates... \def\pgfcalendarprefix{#1}% \pgfcalendardatetojulian{#2}{\pgfcalendarcurrentjulian}% \edef\pgfcalendarbeginjulian{\the\pgfcalendarcurrentjulian}% @@ -163,7 +164,7 @@ % When the key-value code is executed, the following macros will have % been setup: % -% \pgfcalendarifdatejulian +% \pgfcalendarifdatejulian % Julian day number of day to be checked % % \pgfcalendarifdateweekday @@ -173,13 +174,13 @@ % Year of day to be checked % % \pgfcalendarifdatemonth -% Month of day to be chjeck +% Month of day to be checked % % \pgfcalendarifdateday % Day of month of day to be checked % % The setting of these macros will persist after the call, so a -% sideeffect of callling this macro is to setup these macros. +% side-effect of calling this macro is to setup these macros. % % By setting \ifpgfcalendar@do@not@recompute to false, the computation % of the year, month etc. is suppressed. @@ -212,7 +213,7 @@ % % Set match to false \pgfcalendarmatchesfalse% - \pgfqkeys{/pgf/calendar}{#1}% + \pgfqkeys{/pgf/calendar}{#1}% \ifpgfcalendarmatches% #2% \else% @@ -290,7 +291,7 @@ \def\pgfcalendar@special@datetojulian#1{% \edef\pgf@temp{#1}% - \expandafter\pgfcalendar@special@split@test\pgf@temp-\relax{#1}% + \expandafter\pgfcalendar@special@split@test\pgf@temp-\relax{#1}% } \def\pgfcalendar@special@split@test#1-#2-#3\relax#4{% @@ -342,7 +343,7 @@ % % Description: % -% The conversion is taken from the Wikipedia entry on Julian days. +% The conversion is taken from the Wikipedia entry on Julian days. % % The date specification works as follows: % @@ -370,7 +371,7 @@ {% % % Store year, month and days. - % + % \count1=#1\relax% \count2=#2\relax% % If #3=="last", then calculate first day of next month @@ -447,18 +448,18 @@ \ifx\pgf@temp\pgfcalendar@last@text% \advance\count7by-1\relax% \fi% - % Add offset + % Add offset \advance\count7by\count8\relax% \expandafter% }% - \expandafter#5\the\count7\relax% + \expandafter#5\the\count7\relax% } \def\pgfcalendar@last@text{last} \def\pgfcalendar@unpack#1+{% \count8=#1\relax% } -% Convert Julian day number date. +% Convert Julian day number date. % % #1 = the number of Julian days % #2 = a macro in which the year should be stored. @@ -492,23 +493,23 @@ {% % 1) J = Julian day number \count1=#1\relax% - % 2) j = J + 32044 + % 2) j = J + 32044 \count2=\count1\relax% \advance\count2 by 32044\relax% - % 3) g = j div 146097 + % 3) g = j div 146097 \count3=\count2\relax% \divide\count3 by 146097\relax% - % 4) dg = j mod 146097 + % 4) dg = j mod 146097 \count4=\count3\relax% \multiply\count4 by-146097\relax% \advance\count4 by\count2\relax% - % 5) c = (dg div 36524 + 1) * 3 div 4 + % 5) c = (dg div 36524 + 1) * 3 div 4 \count5=\count4\relax% \divide\count5 by36524\relax% \advance\count5 by1\relax% \multiply\count5 by3\relax% \divide\count5 by4\relax% - % 6) dc = dg - c * 36524 + % 6) dc = dg - c * 36524 \count6=\count4\relax% \count0=\count5\relax% \multiply\count0 by-36524\relax% @@ -571,15 +572,15 @@ \advance\count15 by1\relax% % 16)D = d + 1 \count16=\count13% - \advance\count16by 1\relax% + \advance\count16by 1\relax% % \xdef\pgf@temp@year{\the\count14}% \xdef\pgf@temp@month{\ifnum\count15<10 0\fi\the\count15}% \xdef\pgf@temp@day{\ifnum\count16<10 0\fi\the\count16}% }% \let#2=\pgf@temp@year% - \let#3=\pgf@temp@month% - \let#4=\pgf@temp@day% + \let#3=\pgf@temp@month% + \let#4=\pgf@temp@day% } @@ -620,11 +621,11 @@ % October 1st, 2006 was a \pgfcalendarweekdayname{\myweekday} \def\pgfcalendarweekdayname#1{% - \translate{\ifcase#1Monday\or Tuesday\or Wednesday\or Thursday\or Friday\or Saturday\or Sunday\fi}% + \pgfutil@translate{\ifcase#1Monday\or Tuesday\or Wednesday\or Thursday\or Friday\or Saturday\or Sunday\fi}% } \def\pgfcalendarweekdayshortname#1{% - \translate{\ifcase#1Mon\or Tue\or Wed\or Thu\or Fri\or Sat\or Sun\fi}% + \pgfutil@translate{\ifcase#1Mon\or Tue\or Wed\or Thu\or Fri\or Sat\or Sun\fi}% } @@ -637,13 +638,13 @@ % \pgfcalendarmonthname \def\pgfcalendarmonthname#1{% - \translate{\ifcase#1\or January\or February\or March\or April\or + \pgfutil@translate{\ifcase#1\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi}% } \def\pgfcalendarmonthshortname#1{% - \translate{\ifcase#1\or Jan\or Feb\or Mar\or Apr\or + \pgfutil@translate{\ifcase#1\or Jan\or Feb\or Mar\or Apr\or May\or Jun\or Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi}% } @@ -678,7 +679,7 @@ % t = textual representation (allowed only for d, m, w) % . = abbreviated textual representation (allowed only for d, m, w) % -% It is adivsed that you say, for example, +% It is advised that you say, for example, % \let\%=\pgfcalendarshorthand. % % With this setting, you can typeset an ISO-date by saying \%y0-\%m0-\%d0. @@ -713,5 +714,87 @@ \expandafter\def\csname pgfcalendar@shorthand@mt\endcsname{% \pgfcalendarmonthname{\pgfcalendarcurrentmonth}} +% Calculate the date of Easter + +% Credits to HÃ¥kon Malmedal on TeX.SX https://tex.stackexchange.com/a/57243 +% and Donald Knuth, TAoCP, Vol 1, 3rd Ed, Section 1.3.2, Algorithm E, p. 160. + +\newcount\pgf@cal@easter@Y +\newcount\pgf@cal@easter@G +\newcount\pgf@cal@easter@C +\newcount\pgf@cal@easter@X +\newcount\pgf@cal@easter@Z +\newcount\pgf@cal@easter@D +\newcount\pgf@cal@easter@E +\newcount\pgf@cal@easter@N +\newcount\pgf@cal@easter@M +\newcount\pgf@cal@easter@julianday + +\pgfutil@protected\def\pgfcalendareastersunday#1#2{% + \pgfintset\pgf@cal@easter@Y{#1}% + % E1. Golden number + \pgfintset\pgf@cal@easter@G{% + \pgfintmod{\pgf@cal@easter@Y}{19}+1 + }% + % E2. Century + \pgfintset\pgf@cal@easter@C{% + \pgfintdivfloor{\pgf@cal@easter@Y}{100}+1 + }% + % E3. Corrections + \pgfintset\pgf@cal@easter@X{% + \pgfintdivfloor{3*\pgf@cal@easter@C}{4}-12 + }% + \pgfintset\pgf@cal@easter@Z{% + \pgfintdivfloor{8*\pgf@cal@easter@C+5}{25}-5 + }% + % E4. Find Sunday + \pgfintset\pgf@cal@easter@D{% + \pgfintdivfloor{5*\pgf@cal@easter@Y}{4}-\pgf@cal@easter@X-10 + }% + % E5. Epact (full moon) + \pgfintset\pgf@cal@easter@E{% + \pgfintmod{11*\pgf@cal@easter@G+20+\pgf@cal@easter@Z-\pgf@cal@easter@X}{30} + }% + \ifnum\pgf@cal@easter@E<0 + \pgfintset\pgf@cal@easter@E{\pgf@cal@easter@E+30}% + \fi + \ifnum\pgf@cal@easter@E=25 + \ifnum\pgf@cal@easter@G>11 + \pgfintset\pgf@cal@easter@E{\pgf@cal@easter@E+1}% + \fi + \else + \ifnum\pgf@cal@easter@E=24 + \pgfintset\pgf@cal@easter@E{\pgf@cal@easter@E+1}% + \fi + \fi + % E6. Find full moon + \pgfintset\pgf@cal@easter@N{44-\pgf@cal@easter@E}% + \ifnum\pgf@cal@easter@N<21 + \pgfintset\pgf@cal@easter@N{\pgf@cal@easter@N+30}% + \fi + % E7. Advance to Sunday + \pgfintset\pgf@cal@easter@N{% + \pgf@cal@easter@N+7-\pgfintmod{\pgf@cal@easter@D+\pgf@cal@easter@N}{7} + }% + % E8. Get month + \ifnum\pgf@cal@easter@N>31 + \pgfintset\pgf@cal@easter@N{\pgf@cal@easter@N-31}% + \pgfintset\pgf@cal@easter@M{4}% April + \else + \pgfintset\pgf@cal@easter@M{3}% March + \fi + \pgfcalendardatetojulian + {\pgf@cal@easter@Y-\pgf@cal@easter@M-\pgf@cal@easter@N}% + {#2}% +} + +\pgfkeys{/pgf/calendar/Easter/.cd,.default=0,.code={% + \show\pgfcalendarifdateyear + \pgfcalendareastersunday{\pgfcalendarifdateyear}{\pgf@cal@easter@julianday}% + \ifnum\pgfcalendarifdatejulian=\pgfinteval{\pgf@cal@easter@julianday+#1} + \expandafter\pgfcalendarmatchestrue + \fi}% +} + \endinput |