echo "Labor Day Observed (First Monday in September) = " . get_holiday( $y,
9, 1, 1 );
//Grandparents' Day, Sunday after Labor Day
echo "Grandparents' Day (Sunday after Labor Day) = " . get_holiday( ?, ?, ?,
? );
Using these functions, is it possible to determine GP day ?
function format_date( $year, $month, $day )
{
if ( strlen( $month ) == 1 ) {
$month = "0" . $month;
}
if ( strlen( $day ) == 1 ) {
$day = "0" . $day;
}
// $date = $year . "-" . $month . "-" . $day; //YYYY-MM-DD
$date = $month . "-" . $day . "-" . $year; //MM-DD-YYYY
return $date;
}
function get_holiday( $year, $month, $day_of_week, $week = "" )
{
if ( ( ( $week != "" ) && ( ( $week > 5 ) || ( $week < 1 ) ) ) || (
$day_of_week > 6 ) || ( $day_of_week < 0 ) ) {
// $day_of_week must be between 0 and 6 (Sun=0, ... Sat=6); $week must be
between 1 and 5
return false;
} else {
if ( !$week || ( $week == "" ) ) {
$lastday = date( "t", mktime( 0, 0, 0, $month, 1, $year ) );
$temp = ( date( "w", mktime( 0, 0, 0, $month, $lastday, $year ) ) -
$day_of_week ) % 7;
} else {
$temp = ( $day_of_week - date( "w", mktime( 0, 0, 0, $month, 1,
$year ) ) ) % 7;
}
if ( $temp < 0 ) {
$temp += 7;
}
if ( !$week || ( $week == "" ) ) {
$day = $lastday - $temp;
} else {
$day = ( 7 * $week ) - 6 + $temp;
}
return format_date( $year, $month, $day );
}
}
On Wed, 10 Mar 2004 15:48:55 -0900, "News" <ne...@news.com> wrote:
>All,
>These are some functions I am using to calculate holidays, however,
>Grandparents Day seems to be giving me some trouble.
>This is what I am using to determine Labor Day (since GP day is the Sunday
>after):
>
>echo "Labor Day Observed (First Monday in September) = " . get_holiday( $y,
>9, 1, 1 );
>//Grandparents' Day, Sunday after Labor Day
>echo "Grandparents' Day (Sunday after Labor Day) = " . get_holiday( ?, ?, ?,
>? );
>
>Using these functions, is it possible to determine GP day ?
>
If you have a database handy,
make an Excel sheet with all days for the next 10 years and fill in
the LAbour Days into a column as 1. You can then much more easily find
out what 'fetaures' a day has, and its easy to debug.
HTH, Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
"News" <ne...@news.com> wrote in message
news:104vdrp...@corp.supernews.com...