Skip to content
Snippets Groups Projects
pgflibrarycalendar.easter.def 3.13 KiB
% Copyright © 2017
%	Qrrbrbirlbel
%
% Provided that these terms and disclaimer and all copyright notices
% are retained or reproduced in an accompanying document, permission
% is granted to deal in this work without restriction, including un‐
% limited rights to use, publicly perform, distribute, sell, modify,
% merge, give away, or sublicence.
%
% This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
% the utmost extent permitted by applicable law, neither express nor
% implied; without malicious intent or gross negligence. In no event
% may a licensor, author or contributor be held liable for indirect,
% direct, other damage, loss, or other issues arising in any way out
% of dealing in the work, even if advised of the possibility of such
% damage or existence of a defect, except proven that it results out
% of said person’s immediate fault when using the work as intended.

% This is made for http://tex.stackexchange.com/a/144186/16595
% and used the formula from https://de.wikibooks.org/w/index.php?title=Algorithmensammlung:_Kalender:_Feiertage&oldid=670965

\def\pgfcalendar@Easter#1{%
 \begingroup
   \count0=#1\relax              % Yeah 0
   \count1=\count0%              % K 1
   \divide\count1 100            % K 1
   \count2=\count1               % M 3
   \multiply\count2 3
   \advance\count2 3
   \divide\count2 4              % 2 holds (3 * K +3) \ 4
   \count3=\count1
   \multiply\count3 8
   \advance\count3 13
   \divide\count3 -25
   \advance\count3\count2
   \advance\count3 15           % M 3
   \count2-\count2              % S 2
   \advance\count2 2
   \count4=\count0              % A 4
   \divide\count4 19
   \multiply\count4 -19
   \advance\count4\count0       % A 4
   \count1=\count4              % D 1 *
   \multiply\count1 19
   \advance\count1\count3
   \count5\count1
   \divide\count1 30
   \multiply\count1 -30
   \advance\count1\count5       % D 1 *
   \divide\count4 11            % R 4 *
   \advance\count4\count1
   \divide\count4 29            % R 4 *
   \advance\count1-\count4      % OG 1 **
   \advance\count1 21           % OG 1 **
   \count3\count0               % SZ 3 *
   \divide\count3 4
   \advance\count3\count0
   \advance\count3\count2
   \count4-\count3
   \divide\count3 7
   \multiply\count3 7
   \advance\count3\count4
   \advance\count3 7           % SZ 3 *
   \count4-\count3             % OE 4 **
   \advance\count4\count1
   \count3-\count4
   \divide\count4 7
   \multiply\count4 7
   \advance\count4\count3
   \advance\count4 7           % OE 4 **
   \advance\count4\count1
   \pgfcalendardatetojulian{\the\count0-03-\the\count4}\pgfutil@tempcnta
   \expandafter\xdef\csname pgfcalendar@Easter@\the\count0\endcsname
     {\the\pgfutil@tempcnta}%
 \endgroup}
\pgfqkeys{/pgf/calendar/Easter}{
  .default=0,
  .code={%
      \expandafter\ifx\csname pgfcalendar@Easter@\pgfcalendarifdateyear\endcsname\relax
        \pgfcalendar@Easter{\pgfcalendarifdateyear}%
      \fi
      \expandafter\pgfutil@tempcnta
        \csname pgfcalendar@Easter@\pgfcalendarifdateyear\endcsname
      \advance\pgfutil@tempcnta#1\relax
      \ifnum\pgfcalendarifdatejulian=\pgfutil@tempcnta
        \pgfcalendarmatchestrue
      \fi}}