Example #1
0
 /**
  * @see Object\ClassDefinition\Data::getVersionPreview
  * @param \Zend_Date|\DateTime $data
  * @param null|Object\AbstractObject $object
  * @param mixed $params
  * @return string
  */
 public function getVersionPreview($data, $object = null, $params = [])
 {
     if ($data instanceof \Zend_Date) {
         return $data->get(\Zend_Date::DATE_MEDIUM);
     } elseif ($data instanceof \DateTimeInterface) {
         return $data->format("Y-m-d");
     }
 }
Example #2
0
 /**
  * Converts a date-entity to an LDAP-compatible date-string
  *
  * The date-entity <var>$date</var> can be either a timestamp, a
  * DateTime Object, a string that is parseable by strtotime() or a Zend_Date
  * Object.
  *
  * @param    integer|string|DateTimt|Zend_Date        $date    The date-entity
  * @param    boolean                                    $asUtc    Whether to return the LDAP-compatible date-string
  *                                                          as UTC or as local value
  * @return    string
  * @throws    InvalidArgumentException
  */
 public static function toLdapDateTime($date, $asUtc = true)
 {
     if (!$date instanceof DateTime) {
         if (is_int($date)) {
             $date = new DateTime('@' . $date);
             $date->setTimezone(new DateTimeZone(date_default_timezone_get()));
         } else {
             if (is_string($date)) {
                 $date = new DateTime($date);
             } else {
                 if ($date instanceof Zend_Date) {
                     $date = new DateTime($date->get(Zend_Date::ISO_8601));
                 } else {
                     throw new InvalidArgumentException('Parameter $date is not of the expected type');
                 }
             }
         }
     }
     $timezone = $date->format('O');
     if (true === $asUtc) {
         $date->setTimezone(new DateTimeZone('UTC'));
         $timezone = 'Z';
     }
     if ('+0000' === $timezone) {
         $timezone = 'Z';
     }
     return $date->format('YmdHis') . $timezone;
 }
Example #3
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->dateTime = DateTime::get()->setTimestamp('1432674145')->setTimezone(new \DateTimeZone('Europe/London'));
 }