Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
- To: "MLUG Off-Topic Discussion" <EMAIL:PROTECTED>
- Subject: RE: [MLUG - DISCUSSION] Computing the Date of Easter
- From: "Woodsmall, Ryan \(IATS\)" <EMAIL:PROTECTED>
- Date: Thu, 8 Apr 2004 14:18:49 -0500
- Reply-to: MLUG Off-Topic Discussion <EMAIL:PROTECTED>
- Sender: EMAIL:PROTECTED
- Thread-index: AcQdnF000ZsnTXh3QGKkVYL5UbrsUgAABIjA
- Thread-topic: [MLUG - DISCUSSION] Computing the Date of Easter
>From the Time::Local man page:
Please note, however, that the range of dates that can be actually be
handled depends on the size of an integer (time_t) on a given
platform.
Currently, this is 32 bits for most systems, yielding an approximate
range from Dec 1901 to Jan 2038.
The Perl time stuff does NOT like dates before 1902 or after 2037. It
craps out. The first bit of code should work better for dates. I knew
there was a reason that I didn't just use the timelocal() stuff; I just
didn't know why... I promise.
Here's another addendum. Now I know why open source developers get so
uppity when you ask them for new features, bug fixes, etc. :) This
version has 2 space day padding and 4 space year padding. This should
be sufficient for anything up until 999. Maybe? This is, of course,
released under the Magick License: If it works for you, it's magic.
### BEGIN ###
#!/usr/local/bin/perl5
@month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
if($#ARGV < 0){
push(@years, (localtime(time()))[5] + 1900);
}else{
while(@ARGV){
$tmp = shift(@ARGV);
if($tmp =~ m/\d\.\.\d/){
($start, $end) = split("\\.\\." , $tmp);
push(@years, $start..$end);
}elsif($tmp =~ m/\d-\d/){
($start, $end) = split("-" , $tmp);
push(@years, $start..$end);
}else{
push(@years, $tmp);
}
}
}
print("easter falls on the following ");
$#years ? print("days:\n") : print("day:\n");
foreach $y(@years){
$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 * (int($m/4));
printf("%s %s %2d, %4d\n", "Sun", $month[$m - 1], $d, $y);
}
### END ###
ryan woodsmall
EMAIL:PROTECTED
> -----Original Message-----
> From: EMAIL:PROTECTED
> [mailto:EMAIL:PROTECTED] On Behalf Of Mike Miller
> Sent: Thursday, April 08, 2004 2:04 PM
> To: MLUG Off-Topic Discussion
> Subject: RE: [MLUG - DISCUSSION] Computing the Date of Easter
>
> On Thu, 8 Apr 2004, Woodsmall, Ryan (IATS) wrote:
>
> > Number two:
>
>
> This one fails for years greater than 2037. I assume it is a
> victim of
> the infamous C date bug.
>
> Mike
_______________________________________________
discussion mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/discussion