Go Back   IceInSpace > General Astronomy > General Chat
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread
  #1  
Old 08-04-2012, 11:58 AM
astroron's Avatar
astroron (Ron)
Supernova Searcher

astroron is offline
 
Join Date: Mar 2005
Location: Cambroon Queensland Australia
Posts: 9,326
Exclamation I thought picking the date for Easter was easy

Picking the date was I thought just so easy, Sunday closest to Full Moon Ect,
Not So.
http://www.rmg.co.uk/explore/astrono...date-of-easter
Quite complicated really
Happy Easter
cheers
Reply With Quote
  #2  
Old 08-04-2012, 02:45 PM
mithrandir's Avatar
mithrandir (Andrew)
Registered User

mithrandir is offline
 
Join Date: Jan 2009
Location: Glenhaven
Posts: 4,161
Ron, since just about everyone has Perl on their computers these days:

Code:
#!/usr/bin/perl -w
use POSIX;

$y=($#ARGV>-1)?$ARGV[0]:strftime('%Y',localtime())
  or die("$0: year required\n");

$c = int($y/100);
$n = $y-19*int($y/19);
$k = int(($c-17)/25);
$i = $c-int($c/4)-int(($c-$k)/3)+19*$n+15;
$i = $i-30*int($i/30);
$i = $i-int($i/28)*(1-int($i/28)*int(29/($i+1))*int((21-$n)/11));
$j = $y+int($y/4)+$i+2-$c+int($c/4);
$j = $j-7*int($j/7);
$l = $i-$j;
$m = 3+int(($l+40)/44);
$d = $l+28-31*($m/4);
@when=(0,0,0,$d,$m-1,$y-1900);
print strftime("%Y/%b/%d\n",@when);
or if you install the Date::Easter module:

Code:
#!/usr/bin/perl -w
use POSIX;
use Date::Easter;

$y=($#ARGV>-1)?$ARGV[0]:strftime('%Y',localtime())
  or die("$0: year required\n");

($M,$D)=gregorian_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d gregorian\n",@when);

($M,$D)=julian_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d julian\n",@when);

($M,$D)=orthodox_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d orthodox\n",@when);
The first version is probably simpler in C.
Reply With Quote
  #3  
Old 08-04-2012, 03:48 PM
leon's Avatar
leon
Registered User

leon is offline
 
Join Date: Apr 2006
Location: Warrnambool
Posts: 12,797
Ya learn something every day.

Leon
Reply With Quote
  #4  
Old 08-04-2012, 04:31 PM
Barrykgerdes
Registered User

Barrykgerdes is offline
 
Join Date: Feb 2007
Location: Beaumont Hills NSW
Posts: 2,900
I have a calendar. I get a new one every year. It has the dates of Easter, School holidays, other public holidays etc. no need for a computer program.
Besides every day is a holiday for me!

Barry

PS I also have a program in qbasic that can do the same.
Reply With Quote
  #5  
Old 08-04-2012, 05:12 PM
astroron's Avatar
astroron (Ron)
Supernova Searcher

astroron is offline
 
Join Date: Mar 2005
Location: Cambroon Queensland Australia
Posts: 9,326
Quote:
Originally Posted by mithrandir View Post
Ron, since just about everyone has Perl on their computers these days:

Code:
#!/usr/bin/perl -w
use POSIX;

$y=($#ARGV>-1)?$ARGV[0]:strftime('%Y',localtime())
  or die("$0: year required\n");

$c = int($y/100);
$n = $y-19*int($y/19);
$k = int(($c-17)/25);
$i = $c-int($c/4)-int(($c-$k)/3)+19*$n+15;
$i = $i-30*int($i/30);
$i = $i-int($i/28)*(1-int($i/28)*int(29/($i+1))*int((21-$n)/11));
$j = $y+int($y/4)+$i+2-$c+int($c/4);
$j = $j-7*int($j/7);
$l = $i-$j;
$m = 3+int(($l+40)/44);
$d = $l+28-31*($m/4);
@when=(0,0,0,$d,$m-1,$y-1900);
print strftime("%Y/%b/%d\n",@when);
or if you install the Date::Easter module:

Code:
#!/usr/bin/perl -w
use POSIX;
use Date::Easter;

$y=($#ARGV>-1)?$ARGV[0]:strftime('%Y',localtime())
  or die("$0: year required\n");

($M,$D)=gregorian_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d gregorian\n",@when);

($M,$D)=julian_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d julian\n",@when);

($M,$D)=orthodox_easter($y);
@when=(0,0,0,$D,$M-1,$y-1900);
print strftime("%Y/%b/%d orthodox\n",@when);
The first version is probably simpler in C.

I wouldn't know where to start, I don't understand any of that stuff
Cheers
Reply With Quote
  #6  
Old 08-04-2012, 06:27 PM
xstream's Avatar
xstream (John)
Grey Nomad

xstream is offline
 
Join Date: Feb 2005
Location: "Where ever the wind blows".
Posts: 5,694
Quote:
Originally Posted by astroron View Post
I wouldn't know where to start, I don't understand any of that stuff
Cheers
It's easy Ron!

Perl 1, Knit 2.
Reply With Quote
  #7  
Old 08-04-2012, 06:43 PM
astroron's Avatar
astroron (Ron)
Supernova Searcher

astroron is offline
 
Join Date: Mar 2005
Location: Cambroon Queensland Australia
Posts: 9,326
Quote:
Originally Posted by xstream View Post
It's easy Ron!

Perl 1, Knit 2.

Cheers Alex
Reply With Quote
  #8  
Old 08-04-2012, 06:56 PM
skysurfer's Avatar
skysurfer
Dark sky rules !

skysurfer is offline
 
Join Date: Dec 2011
Location: 33S 150E (AU holiday)
Posts: 1,181
And here the Javascript implementation:

Code:
 /**
  * @param year   the year of which easter has to be calculated
  * @param option calculate other date than easter (offset in days)
  * @returns JD of Easter date
  */

function easter(year, option)
{
    var golden, solar, lunar, pfm, dom, tmp, easterday,d;

    /* the Golden number */
    golden = (year % 19) + 1;

    if ( year <= 1752 )
    {
        /* JULIAN CALENDAR */
        /* the "Dominical number" - finding a Sunday */
        dom = (year + Math.floor(year/4) + 5) % 7;
        if (dom < 0) dom += 7;

        /* uncorrected date of the Paschal full moon */
        pfm = (3 - (11*golden) - 7) % 30;
        if (pfm < 0) pfm += 30;
    }
    else
    {
        /* GREGORIAN CALENDAR */
        /* the "Dominical number" - finding a Sunday */
        dom = (year + Math.floor(year/4) - Math.floor(year/100) + Math.floor(year/400)) % 7;
        if (dom < 0) dom += 7;

        /* the solar and lunar corrections */
        solar = Math.floor((year-1600)/100) - Math.floor((year-1600)/400);
        lunar = Math.floor((Math.floor((year-1400) / 100) * 8) / 25);

        /* uncorrected date of the Paschal full moon */
        pfm = (3 - (11*golden) + solar - lunar) % 30;
        if (pfm < 0) pfm += 30;
    }

    /* corrected date of the Paschal full moon - days after 21st March */
    if ((pfm == 29) || (pfm == 28 && golden > 11))
      pfm--;

    tmp = (4-pfm-dom) % 7;
    if (tmp < 0) tmp += 7;

    /* easterday as the number of days after 21st March */
    easterday = pfm + tmp + 1;

//alert(year + ' ' + tmp + ' ' + easterday);

    if (easterday < 11)
        d = datetojd(new Array(year,3, easterday+21,12,0,0));
    else
        d = datetojd(new Array(year,4, easterday-10,12,0,0));
    if (arguments.count > 1)
      d += option;
    d = Math.floor(d);
    return d;
}


function datetojd(datestr)
{
  n = datestr;  // array assumed y-m-d-h-i-s
  var date = new Date(n[0],n[1]-1, n[2], n[3], n[4], n[5]);
   var jd = date.getTime()/86400000 + 2440588 - (date.getTimezoneOffset()/1440);
//alert(jd + ' ' + (date.getTime()/86400000 + 2440588));
   return jd;
}
Reply With Quote
  #9  
Old 08-04-2012, 07:41 PM
mithrandir's Avatar
mithrandir (Andrew)
Registered User

mithrandir is offline
 
Join Date: Jan 2009
Location: Glenhaven
Posts: 4,161
One C++ source for easter is part of lunar.zip from Project Pluto

It compiles, with its driver test program, by:
*nix/cygwin: g++ -DTEST_CODE -o easter easter.cpp
MSVC: cl -DTEST_CODE -o easter.exe easter.cpp

Now, who has it in Java, Pascal, REXX, Python, ...

Reply With Quote
  #10  
Old 08-04-2012, 08:08 PM
ballaratdragons's Avatar
ballaratdragons (Ken)
The 'DRAGON MAN'

ballaratdragons is offline
 
Join Date: Jan 2005
Location: In the Dark at Snake Valley, Victoria
Posts: 14,412
This thread make absolutely no sense to me.

Must be a foreign language.

Don't worry Ron, you aren't alone in the confusion

Reply With Quote
  #11  
Old 09-04-2012, 01:06 AM
Ric's Avatar
Ric
Support your local RFS

Ric is offline
 
Join Date: May 2006
Location: Wamboin NSW
Posts: 12,405
It is interesting how it is worked out.

I understand a bit of that code but it's all a bit above me.
Reply With Quote
  #12  
Old 09-04-2012, 04:43 AM
von Tom's Avatar
von Tom (Tom)
Registered User

von Tom is offline
 
Join Date: Dec 2010
Location: Brisbane
Posts: 1,405
A Perl of wisdom from Andrew there...
Anyone got it in BASIC?
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time is now 06:22 AM.

Powered by vBulletin Version 3.8.7 | Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Advertisement
Bintel
Advertisement