Does anyone have any ideas how (from a script) I can determine whether a date is a (UK) bank holiday?
Something I can use from PHP preferred but I'm flexible.
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.
The message 49DC5B3E.20607@quarella.co.uk from Mark Rogers mark@quarella.co.uk contains these words:
Does anyone have any ideas how (from a script) I can determine whether a date is a (UK) bank holiday?
Something I can use from PHP preferred but I'm flexible.
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.
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); }
Dave Crisp wrote:
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.
Thanks for that - easy to convert to PHP if I go that route.
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)
I hadn't realised it was that "simple". This might be a good way to do it - thanks.
(Ted Harding) wrote:
How far ahead are you thinking of planning for? There are only eight per year for England, so a 3-year look-ahead would take up a couple of dozen lines in a file which you could look up with a little 'awk' or similar script
A small look-up table like this did cross my mind - as you say the table will be short enough and the information is readily available to populate the table.
This gives me two fairly distinct but equally good ways forward, maybe I need to find a spare coin to toss!
You'll need the first and last Monday in May, the last Monday in August, the two working days after Christmas (if Christmas falls on a weekend), an Easter calculator, any other non-English Bank Holidays, and overrides to cope with events like the Queen's Golden Jubilee and other random Acts of Parliament.
Good luck. Tim.
2009/4/8 Mark Rogers mark@quarella.co.uk:
Does anyone have any ideas how (from a script) I can determine whether a date is a (UK) bank holiday?
Something I can use from PHP preferred but I'm flexible.
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.
-- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0845 45 89 555 Registered in England (0456 0902) at 13 Clarke Rd, Milton Keynes, MK1 1LG
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
Tim Green wrote:
You'll need the first and last Monday in May, the last Monday in August, the two working days after Christmas (if Christmas falls on a weekend), an Easter calculator, any other non-English Bank Holidays, and overrides to cope with events like the Queen's Golden Jubilee and other random Acts of Parliament.
Agreed, but this isn't much different from things like timezone settings (eg date of summertime changeovers) which there are standard solutions for. It would make sense that a library of information be kept somewhere such that "apt-get upgrade" (or equivalent for other distros) would keep the information up-to-date.
If it doesn't already exist, it's my (current!) itch so maybe I should scratch it and start such a project...
At Wed, 08 Apr 2009 09:07:26 +0100, Mark Rogers wrote:
Does anyone have any ideas how (from a script) I can determine whether a date is a (UK) bank holiday?
Something I can use from PHP preferred but I'm flexible.
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.
One fun solution would be writing a module which screen scapes http://www.direct.gov.uk/en/Governmentcitizensandrights/LivingintheUK/DG_073...
Otherwise, searching for "national holiday web service" will probably be the most likely way to find a solution. I had a quick look and found one or two things. (One of them it seemed you had to pay for.) If you have HTTP client libraries (which PHP may have) and XML parsing libraries something like this would probably by quite easy to use.
Richard Lewis wrote:
One fun solution would be writing a module which screen scapes http://www.direct.gov.uk/en/Governmentcitizensandrights/LivingintheUK/DG_073...
That URL doesn't have the feel of one that will still work in a year or two's time!
Otherwise, searching for "national holiday web service" will probably be the most likely way to find a solution. I had a quick look and found one or two things. (One of them it seemed you had to pay for.) If you have HTTP client libraries (which PHP may have) and XML parsing libraries something like this would probably by quite easy to use.
Thanks for this pointer; I haven't found anything directly useful yet but it looks like a possible way forward.
2009/4/8 Mark Rogers mark@quarella.co.uk
Does anyone have any ideas how (from a script) I can determine whether a date is a (UK) bank holiday?
Where in the UK?
England+Wales, Scotland and NI have different dates - http://www.direct.gov.uk/en/Governmentcitizensandrights/LivingintheUK/DG_073...
Worse than that, different places in Scotland have additional holidays - the first reference to that I could find was at http://www.sjib.org.uk/page.php?pageid=92
Greg
Greg Thomas wrote:
Where in the UK?
That doesn't really matter to me; if I have the source of information I can work from there.
England+Wales, Scotland and NI have different dates - http://www.direct.gov.uk/en/Governmentcitizensandrights/LivingintheUK/DG_073...
Worse than that, different places in Scotland have additional holidays
- the first reference to that I could find was at
For the time being I need England only so this would be something to add later, I guess!
England+Wales, Scotland and NI have different dates - http://www.direct.gov.uk/en/Governmentcitizensandrights/LivingintheUK/DG_073...
Worse than that, different places in Scotland have additional holidays
- the first reference to that I could find was at
I used to live in Aberdeen [in the days when i used to earn a living] and quite honestly the 'local holidays' in Scotland would be difficult to include. Half the bank holidays are national and half are 'local'. Aberdeen say chooses theirs and a dozen miles away Stonehaven chooses theirs. So in Summer you can visit say Stonehaven and find all closed as it's a local holiday - yes... an utter pain.
For the time being I need England only so this would be something to add later, I guess!
yes i'd say England only.
james
On 08-Apr-09 08:07:26, Mark Rogers wrote:
Does anyone have any ideas how (from a script) I can determine whether a date is a (UK) bank holiday?
Something I can use from PHP preferred but I'm flexible.
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.
-- Mark Rogers // More Solutions Ltd (Peterborough Office) // 0845 45 89 555 Registered in England (0456 0902) at 13 Clarke Rd, Milton Keynes, MK1 1LG
How far ahead are you thinking of planning for? There are only eight per year for England, so a 3-year look-ahead would take up a couple of dozen lines in a file which you could look up with a little 'awk' or similar script.
Add St Patrick's Day and the Battle of the Boyne for Northern Ireland; and, for Scotland: Hangover Day (2 January), their idiosymcratic Summer Bank Holiday date (4 weeks earlier than the rest), and St Andrew's Day, and you have a total of 13 per year for the UK as a whole.
"Official" data for Bank Holidays 2009-2011 can be found at
http://www.direct.gov.uk/en/Governmentcitizensandrights/ LivingintheUK/DG_073741
[all one line]
along with explanatory text. You have two days left to test your script.
Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 08-Apr-09 Time: 09:40:16 ------------------------------ XFMail ------------------------------