Apparent problem with time zone conversion in caldav backend
-
See https://jira.z-hub.io/browse/ZP-1285
Short version is that all my calendar events not created on the phone (or which get sync’d back to it) are getting start times one hour than they should be – it appears the Zulu times sent down are ignoring DST.
-
I stuck some more debugging in the code and this is what I’m seeing…
02/09/2017 15:12:33 [29640] [DEBUG] [test] BackendCalDAV->_ParseVEventToAS(): Parsing VEvent 02/09/2017 15:12:33 [29640] [DEBUG] [test] TimezoneUtil::GetPhpSupportedTimezone(): 'America/Chicago' is a PHP supported timezone 02/09/2017 15:12:33 [29640] [DEBUG] [test] BackendCalDAV->_GetTimezoneString():using 'America/Chicago' timezone 02/09/2017 15:12:33 [29640] [DEBUG] [test] TimezoneUtil::GetFullTZFromTZName('America/Chicago'): Is a PHP TimeZone, converting
I stuck this right in front of the call to MakeUTCDate @ line 598, in the DTSTART stanza for conversion to the ActiveSync object:
ZLog::Write(LOGLEVEL_DEBUG, sprintf(“Util::MakeUTCDate(): Input
‘%s’, timezone ‘%s’, output ‘%s’, offset ‘%d’”, $value, $timezone, $date->format
(‘Y-m-d H:i:s’), timezone_offset_get($tz, $date)));02/09/2017 15:12:33 [29640] [DEBUG] [test] Caldav->_ParseVEventToSyncObject->DTSTART '20170902T160000' 02/09/2017 15:42:01 [33851] [DEBUG] [test] Util::MakeUTCDate(): Input '20170902T160000', timezone '(GMT-06:00) Central Time (US and Canada', output '2017-09-02 16:00:00', offset '-21600'
And indeed the daylight savings time offset is missing; -21600 is GMT-5, not GMT-5 which is what it should be during DST.
02/09/2017 15:12:33 [29640] [WBXML] [test] O <POOMCAL:StartTime> 02/09/2017 15:12:33 [29640] [WBXML] [test] O 20170902T220000Z 02/09/2017 15:12:33 [29640] [WBXML] [test] O </POOMCAL:StartTime>
Thus it is off by exactly one hour.
Is there some sort of timezone problem with the PHP installation on my server?
-
Aha…
This appears to be wrong:
02/09/2017 15:42:01 [33851] [DEBUG] [test] Util::MakeUTCDate(): Input '20170902T160000', timezone '(GMT-06:00) Central Time (US and Canada', output '2017-09-02 16:00:00', offset '-21600'
What I think we want there is the original timezone specification that PHP understands, which is “America/Chicago”; if I place a “$tz = timezone_open(“America/Chicago”);” just before the conversion then the correct DST offset is picked up. It looks like the PHP code is seeing the “GMT-06:00” and stops there (which makes sense as that’s not a PHP-known timezone string.)
I’ll trace back through the code to figure out where the mistake is and generate a patch on Jira.