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 "Grandparen ts' 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 );
}
}
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 "Grandparen ts' 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 );
}
}
Comment