/** * Checks if the given date is a working day. * * @param \Jyxo\Time\Time $day Date to be checked * @return boolean */ public static function isWorkDay(\Jyxo\Time\Time $day) { $holidays = self::$holidays; // Adds Easter Monday. easter_date is supposed to be buggy http://cz.php.net/manual/en/function.easter-date.php#80664 $year = (int) $day->format('Y'); $days = easter_days($year); // $days returns the number of days from March 21st until the Easter Sunday, +1 because of Monday $holidays[] = date('j.n', strtotime($year . '-03-21 +' . ($days + 1) . ' days')); $isWorkDay = true; if ($day->format('N') > 5) { // Saturday or Sunday $isWorkDay = false; } elseif (in_array($day->format('j.n'), $holidays)) { // Public holiday, hurray! $isWorkDay = false; } return $isWorkDay; }
/** * Creates an email. */ private function create() { $uniqueId = md5(uniqid((string) time())); $hostname = $this->clearHeaderValue($this->getHostname()); // Unique email Id $this->result->messageId = $uniqueId . '@' . $hostname; // Sending time $this->result->datetime = \Jyxo\Time\Time::now(); // Parts boundaries $this->boundary = [1 => '====b1' . $uniqueId . '====' . $hostname . '====', 2 => '====b2' . $uniqueId . '====' . $hostname . '====']; // Determine the message type if (!empty($this->email->attachments)) { // Are there any attachments? if (!empty($this->email->body->alternative)) { // There is an alternative content $this->type = self::TYPE_ALTERNATIVE_ATTACHMENTS; } else { // No alternative content $this->type = self::TYPE_ATTACHMENTS; } } else { // No attachments if (!empty($this->email->body->alternative)) { // There is an alternative content $this->type = self::TYPE_ALTERNATIVE; } else { // No alternative content $this->type = self::TYPE_SIMPLE; } } // Creates header and body $this->createHeader(); $this->createBody(); }