@@ 79-87 (lines=9) @@ | ||
76 | */ |
|
77 | public static function defaultTimezone($timezone = null) |
|
78 | { |
|
79 | if ($timezone !== null) |
|
80 | { |
|
81 | if ( ! $timezone instanceOf DateTimeZone) |
|
82 | { |
|
83 | $timezone = new DateTimeZone($timezone); |
|
84 | } |
|
85 | ||
86 | static::$defaultTimezone = $timezone; |
|
87 | } |
|
88 | ||
89 | return static::$defaultTimezone; |
|
90 | } |
|
@@ 171-180 (lines=10) @@ | ||
168 | else |
|
169 | { |
|
170 | // if timezone is given as a string, convert it |
|
171 | if (is_string($timezone)) |
|
172 | { |
|
173 | $timezone = new DateTimeZone($timezone); |
|
174 | } |
|
175 | ||
176 | // default to default timezone if none is given |
|
177 | elseif ($timezone === null) |
|
178 | { |
|
179 | $timezone = static::defaultTimezone(); |
|
180 | } |
|
181 | ||
182 | $this->datetime = new DateTime($time, $timezone); |
|
183 | static::$lastErrors = DateTime::getLastErrors(); |
|
@@ 224-234 (lines=11) @@ | ||
221 | public function createFromFormat($format = 'local', $time, $timezone = null) |
|
222 | { |
|
223 | // deal with the timezone passed |
|
224 | if ($timezone !== null) |
|
225 | { |
|
226 | if ( ! $timezone instanceOf DateTimeZone) |
|
227 | { |
|
228 | $timezone = new DateTimeZone($timezone); |
|
229 | } |
|
230 | } |
|
231 | else |
|
232 | { |
|
233 | $timezone = static::defaultTimezone(); |
|
234 | } |
|
235 | ||
236 | // custom format pattern lookup |
|
237 | if (array_key_exists($format, static::$patterns)) |
|
@@ 454-464 (lines=11) @@ | ||
451 | */ |
|
452 | public function setTimezone($timezone) |
|
453 | { |
|
454 | if ( ! $timezone instanceOf DateTimeZone) |
|
455 | { |
|
456 | if ($timezone === null) |
|
457 | { |
|
458 | $timezone = static::defaultTimezone(); |
|
459 | } |
|
460 | else |
|
461 | { |
|
462 | $timezone = new DateTimeZone($timezone); |
|
463 | } |
|
464 | } |
|
465 | ||
466 | $this->datetime->setTimezone($timezone); |
|
467 |