The message 49DC5B3E.20607@quarella.co.uk from Mark Rogers mark@quarella.co.uk contains these words:
Since the dates aren't consistent I assume I'm going to need somewhere to look the information up, but I'm not sure where, but it seems like this ought to be a fairly "standard" need. (For my application I need to allow website customers to select a delivery date, which needs to exclude bank holidays.) I'm hoping there's a standard method.
I think you might have problems with Easter every now and again - ISTR that its (precise) position in the year can be a matter of debate, if not compromise.
Easter IS complicated, but the following Perl function gives a correct date for any year in the Gregorian calendar. The associated holidays are then the previous Friday and the following Monday.
The other holidays are easy to compute: the first and last Mondays in May, the last Monday in August, and Dec 25/26 and Jan 1 (or the next non-holiday weekday if these fall at the weekend)
anyway, the Perl...
sub easter() {
use integer; # always round down my $year = shift; my ($a, $b, $c, $d, $e, $f, $g, $h, $i, ,$k, $L, $m, $day, $month);
$a = $year % 19; # Golden Number $b = $year / 100; # Century $c = $year % 100; # Year in century
$d = $b / 4; # Number of "leap" centuries; solar equation is $b - $d $e = $b % 4; # centuries since last "leap" $f = ($b + 8) / 25; $g = ($b - $f +1) / 3; # Lunar correction equation
$h = (19*$a + $b - $d - $g + 15) % 30; # Full moon (epact + solar - lunar + 15)
$i = $c / 4; # Number of leap years so far this century $k = $c % 4; # Years since last leap
$L = (32 + 2*$e + 2*$i - $h - $k) % 7; # Doomsday algorithm to find next sunday $m = ($a + 11*$h + 22*$L) / 451; # "25" correction
$month = (114 + $h + $L - 7*$m) / 31; # 114 = (3*31) + 22 - 1 ie march 22
$day = 1 + (114 + $h + $L - 7*$m) % 31;
return ($month, $day); }