Calendar 1.0.1 Edit an Event - Time Incorrect

When editing an event, the start and end times are incorrect. It appears to be displaying as UTC time, not the event timezone.
This was marked as resolved for both beta8 and 1.0.0, but not fixed and still an issue.
 
Turns out this is somewhat bizarre behaviour in PHP, specifically with it building a date/time object whilst also taking in to account a timezone. I am testing a workaround for it.
 
No kidding, this is one of the silliest things I've encountered.

The first snippet is what the code looked like. It's a short hand way of telling PHP how to interpret a measure of time and in what timezone that time should be offset to. Except it doesn't handle UNIX timestamps for whatever reason.

I've rolled out the change here and you can probably make these edits yourself. If you open library/NixFifty/Calendar/Model/Event.php and go to around line 472, change the following:

PHP:
$startDate = new DateTime('@' . $event['start_date'], $tz);

To the following:

PHP:
$startDate = new DateTime('@' . $event['start_date']);
$startDate->setTimezone($tz);

You'll also need to scroll down a bit and do the same for the end date, so...
PHP:
$endDate = new DateTime('@' . $event['end_date']);

To the following:
PHP:
$endDate = new DateTime('@' . $event['end_date']);
$endDate->setTimezone($tz);

I'll have a proper patch out for this tomorrow. :)
 
Back
Top