diff options
| author | emkael <emkael@tlen.pl> | 2016-06-07 15:17:49 +0200 |
|---|---|---|
| committer | emkael <emkael@tlen.pl> | 2016-06-10 11:46:41 +0200 |
| commit | 823d71ced9b4947b1a5a5ade7245d521ed490061 (patch) | |
| tree | a9a6c7cb0de74ff705e8320c284de423a698f5b5 /app/php/dto/TimezoneDTO.php | |
| parent | df401552aac363655ab8f056a6c910a7611954d6 (diff) | |
* renaming php directory
Diffstat (limited to 'app/php/dto/TimezoneDTO.php')
| -rw-r--r-- | app/php/dto/TimezoneDTO.php | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/app/php/dto/TimezoneDTO.php b/app/php/dto/TimezoneDTO.php deleted file mode 100644 index e4078e6..0000000 --- a/app/php/dto/TimezoneDTO.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -class TimezoneDTO { - - public $Label; - public $Name; - public $Offset; - public $OffsetHours; - public $OffsetMinutes; - public $Location; - public $FirstDayOfTheWeek; - - public function __construct(string $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->Location = $tz->getLocation()['country_code']; - $this->FirstDayOfTheWeek = $this->_getFirstDayOfTheWeek(); - $this->Label = sprintf('UTC%+03d:%02d %s', $this->OffsetHours, $this->OffsetMinutes, $this->Name); - } - - private function _getFirstDayOfTheWeek() { - $dayMapping = json_decode( - file_get_contents( - Prado::getPathOfNamespace('Application.dto.weekdays', '.json') - ), - TRUE - ); - if ($this->Location && isset($dayMapping[$this->Location])) { - return ucfirst($dayMapping[$this->Location]); - } - return ucfirst($dayMapping['001']); - } - - - - public static function __compare(TimezoneDTO $tz1, TimezoneDTO $tz2) { - $diff = $tz1->Offset - $tz2->Offset; - return ($diff == 0) ? strcmp($tz1->Name, $tz2->Name) : $diff; - } - -} - -?> |
