コード例 #1
0
 public static function parse($timezone = null)
 {
     // Parse null
     if ($timezone === null) {
         return DateTimeZoneUtils::getDefaultTimezone();
     }
     // Parse DateTimeZone instances
     if ($timezone instanceof self) {
         return $timezone;
     } else {
         if ($timezone instanceof parent) {
             return new self($timezone);
         } else {
             if ($timezone instanceof DateTime) {
                 return $timezone->getTimezone();
             } else {
                 if ($timezone instanceof PHPDateTime) {
                     return new self($timezone->getTimezone());
                 }
             }
         }
     }
     // If the timezone is a string, make sure the timezone ID is valid, return the default value if not
     if (is_string($timezone)) {
         if (DateTimeZoneUtils::isValidTimezoneId($timezone)) {
             return new self($timezone);
         } else {
             return null;
         }
     }
     // Couldn't parse the timezone, return null
     return null;
 }
コード例 #2
0
 /**
  * Check whether the time is local, which is the same time as in the default timezone.
  *
  * @return bool True if the time is local, false if not.
  */
 public function isLocal()
 {
     return $this->getTimezone()->isLocal(DateTimeZoneUtils::getDefaultTimezone());
 }