Internally uses a \DateTime object. Initialization is possible using almost any date/time format (unix timestamp, SQL form, ...). Requires the Gettext PHP extension or any other implementation of the _(string) translation function.
Author: Jaroslav Hanslík
Author: Jan Kolibač
Author: Roman Řáha
Author: Martin Šamšula
Author: Ondřej Nešpor
Inheritance: implements Serializable
Example #1
0
 /**
  * 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;
 }
Example #2
0
File: Sender.php Project: jyxo/php
 /**
  * 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();
 }