Calendar : Fix double timezone difference date update when timezone is different from UTC - refs BT#19129

pull/3973/head
NicoDucou 4 years ago
parent 544dff6bd8
commit c8ebac03f2
  1. 17
      main/inc/lib/agenda.lib.php

@ -528,20 +528,21 @@ class Agenda
break; break;
} }
// @todo remove comment code // @todo remove comment code
$startDateInLocal = new DateTime($newStartDate, new DateTimeZone($timeZone)); // The code below was not adpating to saving light time but was doubling the difference with UTC time.
// Might be necessary to adapt to update saving light time difference.
/* $startDateInLocal = new DateTime($newStartDate, new DateTimeZone($timeZone));
if ($startDateInLocal->format('I') == 0) { if ($startDateInLocal->format('I') == 0) {
// Is saving time? Then fix UTC time to add time // Is saving time? Then fix UTC time to add time
$seconds = $startDateInLocal->getOffset(); $seconds = $startDateInLocal->getOffset();
$startDate->add(new DateInterval("PT".$seconds."S")); $startDate->add(new DateInterval("PT".$seconds."S"));
//$startDateFixed = $startDate->format('Y-m-d H:i:s'); //$startDateFixed = $startDate->format('Y-m-d H:i:s');
/*$startDateInLocalFixed = new DateTime($startDateFixed, new DateTimeZone($timeZone)); //$startDateInLocalFixed = new DateTime($startDateFixed, new DateTimeZone($timeZone));
$newStartDate = $startDateInLocalFixed->format('Y-m-d H:i:s');*/ //$newStartDate = $startDateInLocalFixed->format('Y-m-d H:i:s');
//$newStartDate = $startDate->setTimezone(new DateTimeZone($timeZone))->format('Y-m-d H:i:s'); //$newStartDate = $startDate->setTimezone(new DateTimeZone($timeZone))->format('Y-m-d H:i:s');
} }
$newStartDate = $startDate->setTimezone(new DateTimeZone($timeZone))->format('Y-m-d H:i:s');
$endDateInLocal = new DateTime($newEndDate, new DateTimeZone($timeZone));
$endDateInLocal = new DateTime($newEndDate, new DateTimeZone($timeZone));
if ($endDateInLocal->format('I') == 0) { if ($endDateInLocal->format('I') == 0) {
// Is saving time? Then fix UTC time to add time // Is saving time? Then fix UTC time to add time
$seconds = $endDateInLocal->getOffset(); $seconds = $endDateInLocal->getOffset();
@ -549,7 +550,9 @@ class Agenda
//$endDateFixed = $endDate->format('Y-m-d H:i:s'); //$endDateFixed = $endDate->format('Y-m-d H:i:s');
//$endDateInLocalFixed = new DateTime($endDateFixed, new DateTimeZone($timeZone)); //$endDateInLocalFixed = new DateTime($endDateFixed, new DateTimeZone($timeZone));
//$newEndDate = $endDateInLocalFixed->format('Y-m-d H:i:s'); //$newEndDate = $endDateInLocalFixed->format('Y-m-d H:i:s');
} }
*/
$newStartDate = $startDate->setTimezone(new DateTimeZone($timeZone))->format('Y-m-d H:i:s');
$newEndDate = $endDate->setTimezone(new DateTimeZone($timeZone))->format('Y-m-d H:i:s'); $newEndDate = $endDate->setTimezone(new DateTimeZone($timeZone))->format('Y-m-d H:i:s');
$list[] = ['start' => $newStartDate, 'end' => $newEndDate]; $list[] = ['start' => $newStartDate, 'end' => $newEndDate];
$counter++; $counter++;

Loading…
Cancel
Save