예제 #1
0
 public function testFromNativeDateTimeZone()
 {
     $nativeTimeZone = new \DateTimeZone('Europe/Madrid');
     $timeZoneFromNative = TimeZone::fromNativeDateTimeZone($nativeTimeZone);
     $constructedTimeZone = new TimeZone(new StringLiteral('Europe/Madrid'));
     $this->assertTrue($timeZoneFromNative->sameValueAs($constructedTimeZone));
 }
 /**
  * Returns a new DateTime from a native PHP \DateTime.
  *
  * @param \DateTime $nativeDatetime
  *
  * @return DateTimeWithTimeZone
  */
 public static function fromNativeDateTime(\DateTime $nativeDatetime)
 {
     $datetime = DateTime::fromNativeDateTime($nativeDatetime);
     $timezone = TimeZone::fromNativeDateTimeZone($nativeDatetime->getTimezone());
     return new static($datetime, $timezone);
 }