Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2013, 07:42 PM   PM User | #1
rgb
New Coder

 
Join Date: Jul 2011
Posts: 12
Thanks: 0
Thanked 2 Times in 2 Posts
rgb is an unknown quantity at this point
Public Holidays in England and Wales as Julian Days

I couldn't find a simple routine for doing this, but found several people asking for one, so I put this together. It could probably be done more elegantly, but it's simple to understand this way. It seems to work ok for the few future years I've tested it for - as long as the Queen doesn't live for another ten years and there isn't another royal wedding!

PHP Code:
<?php

// BANK HOLIDAYS IN ENGLAND AND WALES AS JULIAN DAYS


$statYear 2015;//FOR EXAMPLE


$firstJan cal_to_jd (CAL_GREGORIAN1,1,$statYear );//NEW YEARS DAY - 1st of Jan unless its a Sat or Sun
if ( JDDayOfWeek $firstJan ) == $firstJan += 2;
if ( 
JDDayOfWeek $firstJan ) == $firstJan += 1;

$goodFriday unixtojd (easter_date $statYear )) -2;//GOOD FRIDAY AND EASTER MONDAY determined by Easter Day which is  1st Sunday after 1st full moon after vernal equinox
$easterMonday =  unixtojd (easter_date $statYear  )) +1;

$firstDayThisMonth =  cal_to_jd (CAL_GREGORIAN5,1,$statYear);//MAY BANK HOLIDAY - First Monday in May
for ($i $firstDayThisMonth;$i<= $firstDayThisMonth 6;$i++){
    if (
JDDayOfWeek($i)== 1$mayDay $i;
    }

$firstDayThisMonth =  cal_to_jd (CAL_GREGORIAN5,1,$statYear);//SPRING BANK HOLIDAY - Last Monday in May
for ($i $firstDayThisMonth;$i<= $firstDayThisMonth 30;$i++){
    if (
JDDayOfWeek($i)== 1$springDay $i;
    }


$firstDayThisMonth =  cal_to_jd (CAL_GREGORIAN8,1,$statYear);//SUMMER BANK HOLIDAY - Last Monday in August
for ($i $firstDayThisMonth;$i<= $firstDayThisMonth 30;$i++){
    if (
JDDayOfWeek($i)== 1$summerDay $i;
    }

$xmasDay cal_to_jd (CAL_GREGORIAN12,25,$statYear);//XMAS DAY - 25th of Dec unless its a Sat or Sun
$boxingDay cal_to_jd (CAL_GREGORIAN12,26,$statYear);//BOXING DAY - 26th of Dec unless its a Sat or Sun
if ( JDDayOfWeek $xmasDay ) == $boxingDay += 2;
if ( 
JDDayOfWeek $xmasDay ) == ) {
                    
$xmasDay += 2;
                    
$boxingDay += 2;
                    }
if ( 
JDDayOfWeek $xmasDay ) == ) {
                    
$xmasDay += 1;
                    
$boxingDay += 1;
                    }

$bankHolidays = array ($firstJan,$goodFriday,$easterMonday,$mayDay,$springDay,$summerDay,$xmasDay,$boxingDay);

?>
rgb is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 +1. The time now is 06:37 PM.


Advertisement
Log in to turn off these ads.