Created
September 11, 2018 15:26
-
-
Save summersab/c3c1849e44621660e71ded797f73a335 to your computer and use it in GitHub Desktop.
PHP script to return a JSON object of observed UPS holidays (i.e. days they don't pick up or deliver) using https://github.com/azuyalabs/yasumi.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$UPS = array( | |
"New Year's Day", | |
"New Year's Day observed", | |
"Memorial Day", | |
"Independence Day observed", | |
"Independence Day", | |
"Labour Day", | |
"Thanksgiving Day", | |
"Christmas", | |
"Christmas observed", | |
); | |
$holidays = Yasumi\Yasumi::create('USA', date('Y')); | |
$official = new Yasumi\Filters\OfficialHolidaysFilter($holidays->getIterator()); | |
$json = "["; | |
$i = 0; | |
foreach ($official as $day) { | |
if (in_array($day->getName(), $UPS)) { | |
if ($i) $json = $json . ","; | |
$json = $json . json_encode($day); | |
$i = 1; | |
} | |
} | |
$NYE_check = Yasumi\Yasumi::create('USA', date('Y', strtotime('+1 years'))); | |
if ($NYE_check->getHoliday('substituteHoliday:newYearsDay')) { | |
$json = $json . "," . json_encode($NYE_check->getHoliday('substituteHoliday:newYearsDay')); | |
} | |
$json = $json . "]"; | |
echo $json; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment