Skip to content

Instantly share code, notes, and snippets.

@saetia
saetia / is_federal_holiday.php
Last active August 31, 2019 00:03
is_federal_holiday
<?php
function is_federal_holiday(DateTime $date){
$year = $date->format('Y');
$federal_holidays = array_map(function($date_string) use($year){
$date = new DateTime($date_string . ' ' . $year);
if ($date->format('l') === 'Saturday') $date->modify('-1 day');
if ($date->format('l') === 'Sunday') $date->modify('+1 day');
return $date;
}, [
"january 1", //new year's day