ICEINSPACE
Moon Phase
CURRENT MOON
Waning Gibbous 95.7%
|
|

08-04-2012, 11:58 AM
|
 |
Supernova Searcher
|
|
Join Date: Mar 2005
Location: Cambroon Queensland Australia
Posts: 9,326
|
|
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
|

08-04-2012, 02:45 PM
|
 |
Registered User
|
|
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.
|

08-04-2012, 03:48 PM
|
 |
Registered User
|
|
Join Date: Apr 2006
Location: Warrnambool
Posts: 12,797
|
|
Ya learn something every day.
Leon
|

08-04-2012, 04:31 PM
|
Registered User
|
|
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.
|

08-04-2012, 05:12 PM
|
 |
Supernova Searcher
|
|
Join Date: Mar 2005
Location: Cambroon Queensland Australia
Posts: 9,326
|
|
Quote:
Originally Posted by mithrandir
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
|

08-04-2012, 06:27 PM
|
 |
Grey Nomad
|
|
Join Date: Feb 2005
Location: "Where ever the wind blows".
Posts: 5,694
|
|
Quote:
Originally Posted by astroron
I wouldn't know where to start, I don't understand any of that stuff 
Cheers
|
It's easy Ron!
Perl 1, Knit 2.
|

08-04-2012, 06:43 PM
|
 |
Supernova Searcher
|
|
Join Date: Mar 2005
Location: Cambroon Queensland Australia
Posts: 9,326
|
|
Quote:
Originally Posted by xstream
It's easy Ron!
Perl 1, Knit 2. 
|
  
Cheers Alex
|

08-04-2012, 06:56 PM
|
 |
Dark sky rules !
|
|
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;
}
|

08-04-2012, 07:41 PM
|
 |
Registered User
|
|
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, ...
|

08-04-2012, 08:08 PM
|
 |
The 'DRAGON MAN'
|
|
Join Date: Jan 2005
Location: In the Dark at Snake Valley, Victoria
Posts: 14,412
|
|
|

09-04-2012, 01:06 AM
|
 |
Support your local RFS
|
|
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.
|

09-04-2012, 04:43 AM
|
 |
Registered User
|
|
Join Date: Dec 2010
Location: Brisbane
Posts: 1,405
|
|
A Perl of wisdom from Andrew there...
Anyone got it in BASIC?
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +10. The time is now 06:22 AM.
|
|