Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

What about Easter?

by m.att (Pilgrim)
on Jul 24, 2005 at 16:31 UTC ( #477583=perlmeditation: print w/replies, xml ) Need Help??

An open letter to the Perl Design Team,

I think it's high time that someone finally brought to light but one of the glaring ommissions in the Perl language that has plagued it from day one. I have been using Perl for many years and not a day goes by that I am not disappointed (and frankly, embarassed) in finding missing functionality and clear design errors.

How much longer must we bear the barely muffled snickers of the users of other (truly functional) languages? How much longer must we bear the weight of ludicrous and blatant omissions? And most importantly, does leaving these omissions uncorrected speak well of our community's ability to learn from mistakes and MOVE FORWARD?

I say not!

It is for this reason that I have decided to petition the Perl5 designers for the inclusion of an easter_date() function in the Perl core function library.

Let it be known that I do not stand alone! There are many highly-important and influential people who REQUIRE this function on a day to day basis, and we will no longer take this omission laying down!

I say RISE UP all of you who are tired of hacking your way through this design error!

I say USE YOUR VOICE all those who denounce these hulking modules which do nothing but slow code down and waste valuable disk space!


Please show your support and state your agreement by responding to this post!

Replies are listed 'Best First'.
Re: What about Easter?
by CountZero (Bishop) on Jul 24, 2005 at 18:32 UTC
    Indeed, but only if we also get the functions: jewish_newyear_date, islamic_newyear_date, chinese_newyear_date, eastern_orthodox_easter_date, pre_1583_easter_date and to be totally orthogonal western_newyear_date (I know it is always on January 1st, but we should not let such little issue stop us from being truly multi-cultural and non-western centric.).


    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Now we're talkin!
Re: What about Easter?
by neniro (Priest) on Jul 24, 2005 at 17:03 UTC

      Okay I ported whatever is in the last post of that thread to Perl: (only tested with this year though)

      print easter_date(2005); sub easter_date { my $Year = shift; $G = $Year % 19; $C = int($Year / 100); $H = int($C - ($C / 4) - ((8*$C+13) / 25) + 19*$G + 15) % 30; + $I = $H - int($H / 28)*(1 - int($H / 28)*int(29 / ($H + 1))*( +int(21 - $G) / 11)); $J = ($Year + int($Year/4) + $I + 2 - $C + int($C/4)) % 7; $L = $I - $J; $m = 3 + int(($L + 40) / 44); $d = $L + 28 - 31 * (int($m / 4)); $y = $Year; return sprintf("%04d-%02d-%02d", $y, $m, $d); }


        I wrote a quick and dirty compare of the date calculated by this sub against the list in the zip file at Easter Sunday Dates and found it to be 22% inaccurate. Good enough for PHP perhaps? *grin*

        Yes I get that the thread was a joke :)

        Update: see Re^3: What about Easter? by themage for an updated subroutine which does not produce any erros when compared to the list.

        Murray Barton
        Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

        There is a small error in the PHP version, that pg ported here: <updated, wrong name>.

        The line
        $H = int($C - ($C / 4) - ((8*$C+13) / 25) + 19*$G + 15) % 30;

        Should be:
        $H = ($C - int($C / 4) - int((8*$C+13) / 25) + 19*$G + 15) % 30;

        The final sub sould look like:

        sub easter_date { my $Year = shift; my ($G,$C,$H,$I,$J,$L)="0"x6; $G = $Year % 19; $C = int($Year / 100); $H = ($C - int($C / 4) - int((8*$C+13) / 25) + 19*$G + 15) % 30; $I = $H - int($H / 28)*(1 - int($H / 28)*int(29 / ($H + 1))*(int(21 +- $G) / 11)); $J = ($Year + int($Year/4) + $I + 2 - $C + int($C/4)) % 7; $L = $I - $J; my $m = 3 + int(($L + 40) / 44); my $d = $L + 28 - 31 * (int($m / 4)); my $y = $Year; return sprintf("%04d-%02d-%02d", $y, $m, $d); }
        This way, I think that it should be ok. What you think greenFox?

        Too SLOW! Must be in CORE!
      The slight chuckle that I had after reading the original post was swept away by the shocking realization that someone, somewhere considered this necessary enough to be in the core language. Wow.
Re: What about Easter?
by bart (Canon) on Jul 24, 2005 at 17:43 UTC
    You appear not to know how things work with Perl. Stuff that we don't need in every other script is not supposed to go into core perl (except for the stuff that was already in perl4, for example sockets), but into modules on CPAN. In this case, you should take a look at Date::Easter.

    There's no need at all to reinstall perl, in order to add this module.

Re: What about Easter?
by jpeg (Chaplain) on Jul 24, 2005 at 22:08 UTC
    Cue subthread featuring 5 ways to calculate easter_date in Perl6, of which 3 don't work yet, and a post by timtoady explaining that easter_date was considered for perl 5 but voted out, but that they've fixed the situation for perl 6 and you'll like it better.
      considered for perl 5 but voted out
      Voted?! perl 5? I don't think so.
Re: What about Easter?
by Anonymous Monk on Jul 25, 2005 at 12:27 UTC
    Larry has wanted an easter_date function in Perl ever since Perl 3, saying it's a glaring omission from Perl. But as most people will know, the Easter Bunny holds the copyrights and patents on all that's related to Easter. And while the Bunny grants licenses free of charge to almost anybody, it turns out the Easter Bunny is really Guido van Rossum in a fury suit. And he has denied Perl to the right to include an easter_date() function in Perl.

    Perl6 will likely to have a Western object, with Western falling either half a year before Easter, or half a year after. You can get the Western date by calling the date function in it (it takes a mandatory year as argument):

    print => 4)).as_string();
    Alternatively, there will be a Unicode character for it (one from the 3 upcoming Unicode planes reserved for Perl characters). But there will be a ASCII equivalent, Huffman encoded to 7 characters. Described on page 13,897 of the compact abridged Perl6 pocket reference guide.
      Well, the Easter Bunny's philosophy is: "Free as in eggs, not as in code".
Re: What about Easter?
by m.att (Pilgrim) on Jul 24, 2005 at 16:47 UTC
    Okay okay okay, apparently the line between self-deprecating humour and trolling is very fine. This is an attempt at the former. An easter_date() function is madness.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://477583]
Approved by Old_Gray_Bear
Front-paged by hsmyers
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2021-04-11 07:54 GMT
Find Nodes?
    Voting Booth?

    No recent polls found