Skip to content

Commit

Permalink
Convert event date/time start and end to UTC if date elements ar not …
Browse files Browse the repository at this point in the history
…"store as local"
  • Loading branch information
cheesegrits committed Jan 28, 2016
1 parent a0d82a0 commit 4e6ed01
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
Expand Up @@ -154,10 +154,40 @@ public function addEvForm()

if (!empty($start_date))
{
// check to see if we need to convert to UTC
$startDateEl = $listModel->getFormModel()->getElement($startDateField);

if ($startDateEl !== false)
{
$startStoreAsLocal = $startDateEl->getParams()->get('date_store_as_local', '0') === '1';

if (!$startStoreAsLocal)
{
$localTimeZone = new DateTimeZone($config->get('offset'));
$start_date = new DateTime($start_date, $localTimeZone);
$start_date->setTimeZone(new DateTimeZone('UTC'));
$start_date = $start_date->format('Y-m-d H:i:s');
}
}
$link .= "&$startDateField=" . $start_date;
}
if (!empty($end_date))
{
// check to see if we need to convert to UTC
$endDateEl = $listModel->getFormModel()->getElement($endDateField);

if ($endDateEl !== false)
{
$endStoreAsLocal = $endDateEl->getParams()->get('date_store_as_local', '0') === '1';

if (!$endStoreAsLocal)
{
$localTimeZone = new DateTimeZone($config->get('offset'));
$end_date = new DateTime($end_date, $localTimeZone);
$end_date->setTimeZone(new DateTimeZone('UTC'));
$end_date = $end_date->format('Y-m-d H:i:s');
}
}
$link .= "&$endDateField=" . $end_date;
}

Expand Down
17 changes: 14 additions & 3 deletions plugins/fabrik_visualization/fullcalendar/models/fullcalendar.php
Expand Up @@ -248,9 +248,20 @@ public function setupEvents()
$customUrl = FArrayHelper::getValue($customUrls, $i, '');
$status = FArrayHelper::getValue($stati, $i, '');
$allday = FArrayHelper::getValue($allDayEl, $i, '');
$this->events[$tables[$i]][] = array('startdate' => $startDate, 'enddate' => $endDate, 'startShowTime' => $startShowTime,
'endShowTime' => $endShowTime, 'label' => $table_label[$i], 'colour' => $colour[$i], 'legendtext' => $legend[$i],
'formid' => $table->form_id, 'listid' => $tables[$i], 'customUrl' => $customUrl, 'status' => $status, 'allday' => $allday);
$this->events[$tables[$i]][] = array(
'startdate' => $startDate,
'enddate' => $endDate,
'startShowTime' => $startShowTime,
'endShowTime' => $endShowTime,
'label' => $table_label[$i],
'colour' => $colour[$i],
'legendtext' => $legend[$i],
'formid' => $table->form_id,
'listid' => $tables[$i],
'customUrl' => $customUrl,
'status' => $status,
'allday' => $allday
);
}
}
}
Expand Down

0 comments on commit 4e6ed01

Please sign in to comment.