Merge pull request #55 from v1r0x/fix-timezone

use user's timezone for datetimes
This commit is contained in:
v1r0x 2016-04-27 00:21:30 +02:00
Родитель e05579897a 6fb57600e4
Коммит b253471d92
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -333,10 +333,15 @@ class PageController extends Controller {
$ins = $this->eventMapper->insert($event);
$poll_id = $ins->getId();
sort($chosenDates);
$tz = \OC::$server->getConfig()->getUserValue($this->userId, 'core', 'timezone', 'UTC');
$timezone = new \DateTimeZone($tz);
foreach ($chosenDates as $el) {
$date = new Date();
$date->setPollId($poll_id);
$date->setDt(date('Y-m-d H:i:s', $el));
$dateTime = new \DateTime(date(\DateTime::ATOM, $el), $timezone);
$offset = $timezone->getOffset($dateTime);
$dateTime->setTimestamp($dateTime->getTimestamp() + $timezone->getOffset($dateTime));
$date->setDt($dateTime->format('Y-m-d H:i:s'));
$this->dateMapper->insert($date);
}
} else {