blob: d80d4dd3881ef77da3b73936945a46db88acc936 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<?php
class TimezoneDTO {
public $Label;
public $Name;
public $Offset;
public $OffsetHours;
public $OffsetMinutes;
public function __construct($name) {
$tz = new DateTimeZone($name);
$this->Name = $tz->getName();
$this->Offset = $tz->getOffset(new DateTime());
$this->OffsetHours = $this->Offset / 3600;
$this->OffsetMinutes = $this->Offset % 3600 / 60;
$this->Label = sprintf('UTC%+03d:%02d %s', $this->OffsetHours, $this->OffsetMinutes, $this->Name);
}
public static function __compare(TimezoneDTO $tz1, TimezoneDTO $tz2) {
$diff = $tz1->Offset - $tz2->Offset;
return ($diff == 0) ? strcmp($tz1->Name, $tz2->Name) : $diff;
}
}
?>
|