9
$\begingroup$

The Calendar package, now obsolete, had functionality for "special dates"; in particular, EasterSunday[]. The documentation says it's been subsumed into the Wolfram Language. But it hasn't, at least not to any meaningful degree that I can see. How would I, for example, get the date of Easter Sunday from 1950 - 2050 in a useful form (i.e. something that gives me the equivalent of EasterSunday[#] & /@ Range[1950, 2050]? Free form input is very bad at doing things like this in a straightforward way. I don't care if Easter Sunday 2032 is the 91st anniversary of the Battle of Cape Matapan, I really don't.

$\endgroup$
0

3 Answers 3

6
$\begingroup$
DataPaclets`CalendarDataDump`EasterSunday /@ Range[1950, 2050]
DataPaclets`CalendarDataDump`EasterSundayGreekOrthodox /@ Range[1950, 2050]
$\endgroup$
4
  • 1
    $\begingroup$ Might as well include DataPaclets`CalendarDataDump`EasterSundayGreekOrthodox $\endgroup$
    – Mr.Wizard
    Commented Feb 18, 2015 at 1:20
  • $\begingroup$ I think you made the cardinal sin of adding a superfluous Function. :o) $\endgroup$
    – Mr.Wizard
    Commented Feb 18, 2015 at 1:22
  • 2
    $\begingroup$ I just copied the OP's code and added the context. My family is about and I didn't think... :( $\endgroup$
    – Michael E2
    Commented Feb 18, 2015 at 1:26
  • $\begingroup$ Well, this works, but I do not regard it as a step forward. Directly querying the contents of curated data is a pretty opaque (and sparsely documented) way of going about things. I guess it answers the question, though. $\endgroup$
    – David G
    Commented Feb 18, 2015 at 3:11
9
$\begingroup$

For reference, here is a Mathematica implementation of this algorithm from an anonymous source, and reproduced in a number of other references (e.g. Meeus):

SetAttributes[easter, Listable];
easter[y_Integer] := Module[{y19 = Mod[y, 19], b, c, d, e, h, i, k, l},
       {b, c} = QuotientRemainder[y, 100];
       {d, e} = QuotientRemainder[b, 4]; {i, k} = QuotientRemainder[c, 4];
       h = Mod[19 y19 + b - d - Quotient[b + 1 - Quotient[b + 8, 25], 3] + 15, 30];
       l = Mod[2 e + 2 i - h - k + 32, 7];
       Prepend[QuotientRemainder[h + l - 7 Quotient[y19 + 11 (h + 2 l), 451] +
                                 114, 31] + {0, 1}, y]]

Test:

Table[DataPaclets`CalendarDataDump`EasterSunday[k], {k, 1950, 2000}] ===
easter[Range[1950, 2000]]
   True

As a belated bonus, here is a compact implementation of the computus for Greek Orthodox Easter, based on Meeus's version:

SetAttributes[easterGreek, Listable];
easterGreek[y_Integer] := Module[{p, q, r, u},
            {p, q, r} = Mod[y, {19, 7, 4}]; u = Mod[19 p + 16, 30];
            u = u + Mod[4 q + 2 r + 6 u, 7] + Quotient[y, 100] - Quotient[y, 400] - 12;
            {y, 4 + Boole[u > 30], Mod[u, 30, 1]}]

This should work for the years 1500-5100.

$\endgroup$
7
$\begingroup$

Another undocumented interface similar to the one in Michael E2's answer

Developer`CalendarData[{#}, "Easter"] & /@ Range[1950, 2050]

Also, while the Calendar package has been deprecated, it is still present in the layout, in other words it is still possible to use EasterSunday

Needs["Calendar`"]

EasterSunday /@ Range[1950, 2050]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.