From 81890fab8952f6ee9dcb1f3c0a577472cf7c4fd6 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 16 Mar 2016 01:11:03 +0100 Subject: * respecting timezone preference for events --- app/php/dto/EventDTO.php | 4 +++- app/php/dto/TimezoneDTO.php | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/php/dto/TimezoneDTO.php (limited to 'app/php/dto') diff --git a/app/php/dto/EventDTO.php b/app/php/dto/EventDTO.php index 4a16505..b1042b1 100644 --- a/app/php/dto/EventDTO.php +++ b/app/php/dto/EventDTO.php @@ -15,7 +15,9 @@ class EventDTO { $this->Location = $event->Location; $utc = new DateTimeZone('UTC'); - $targetTz = new DateTimeZone(date_default_timezone_get()); + $targetTz = new DateTimeZone( + Prado::getApplication()->getUser()->getTimezonePreference()->Name + ); $beginDate = new DateTime($event->BeginDate, $utc); $endDate = new DateTime($event->EndDate, $utc); if ($event->AllDay) { 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 @@ +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); + } + +} + +?> -- cgit v1.2.3