Calendar - change how we're dealing with (all day) timezones, keeping the event in the assigned timezone instead of always changing it to the server timezone.

This commit is contained in:
nathangray 2017-05-31 09:55:41 -06:00
parent c5a1bcf1f6
commit 11f3719348
3 changed files with 13 additions and 11 deletions

View File

@ -1116,6 +1116,7 @@ class calendar_bo
// insert at least the event itself, if it's behind the horizont
$event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end;
}
$event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
// unset exceptions, as we need to add them as recurrence too, but marked as exception
unset($event['recur_exception']);
// loop over all recurrences and insert them, if they are after $start

View File

@ -1203,11 +1203,14 @@ class calendar_boupdate extends calendar_bo
{
$old_event = null;
}
if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
// set recur-enddate/range-end to real end-date of last recurrence
if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'])
{
$rrule = calendar_rrule::event2rrule($event);
$event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
$event['recur_enddate']->setTime(23,59,59);
$rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$server_timezone->getName());
$rrule->rewind();
$enddate = $rrule->current();
do
@ -1215,13 +1218,13 @@ class calendar_boupdate extends calendar_bo
$rrule->next_no_exception();
$occurrence = $rrule->current();
}
while ($rrule->valid(true) && ($enddate = $occurrence));
while ($rrule->valid() && ($enddate = $occurrence));
$enddate->modify(($event['end'] - $event['start']).' second');
$event['recur_enddate'] = $enddate->format('ts');
//$enddate->setTimezone();
//$event['recur_enddate'] = $enddate->format('ts');
//error_log(__METHOD__."($event[title]) start=".Api\DateTime::to($event['start'],'string').', end='.Api\DateTime::to($event['end'],'string').', range_end='.Api\DateTime::to($event['recur_enddate'],'string'));
}
if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
$save_event = $event;
if ($event['whole_day'])
{
@ -1247,17 +1250,15 @@ class calendar_boupdate extends calendar_bo
{
// all-day events are handled in server time
$time = $this->so->startOfDay(
new Api\DateTime($event['recur_enddate'], Api\DateTime::$user_timezone),
new Api\DateTime($event['recur_enddate'], Api\DateTime::$server_timezone),
Api\DateTime::$server_timezone->getName()
);
$time->modify(($event['end'] - $event['start'] + 1).' seconds');
$event['recur_enddate'] = Api\DateTime::to($time, 'ts') - 1;
$time->setUser();
$save_event['recur_enddate'] = Api\DateTime::to($time, 'ts') - 1;
$time->modify(($event['end'] - $event['start']).' seconds');
//$event['recur_enddate'] = $save_event['recur_enddate'] = Api\DateTime::to($time, 'ts');
}
$timestamps = array('modified','created');
// all-day events are handled in server time
$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
// $event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
}
else
{

View File

@ -760,7 +760,7 @@ class calendar_rrule implements Iterator
if ($event['recur_enddate'])
{
$enddate = is_a($event['recur_enddate'],'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'],$timestamp_tz);
$enddate->setTime(23,59,59);
// $enddate->setTime(23,59,59);
$enddate->setTimezone(self::$tz_cache[$to_tz]);
}
if (is_array($event['recur_exception']))