diff options
author | emkael <emkael@tlen.pl> | 2016-03-16 01:11:03 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-03-16 01:11:03 +0100 |
commit | 81890fab8952f6ee9dcb1f3c0a577472cf7c4fd6 (patch) | |
tree | 4b3ed536f83f0877e1be6b89cd687d9c0d44c727 /app/php/dto/TimezoneDTO.php | |
parent | aa633881b411c81009d4e1d394d30c950da9c70f (diff) |
* respecting timezone preference for events
Diffstat (limited to 'app/php/dto/TimezoneDTO.php')
-rw-r--r-- | app/php/dto/TimezoneDTO.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/php/dto/TimezoneDTO.php b/app/php/dto/TimezoneDTO.php new file mode 100644 index 0000000..4bb57f2 --- /dev/null +++ b/app/php/dto/TimezoneDTO.php @@ -0,0 +1,22 @@ +<?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); + } + +} + +?> |