fmbiete / Z-Push-contrib

Z-Push fork with changes that I will try to contrib
GNU Affero General Public License v3.0
134 stars 62 forks source link

Timezone issue with calendar sync #236

Closed meitonga closed 8 years ago

meitonga commented 9 years ago

Hi,

I use the latest z-push-contrib version together with Owncloud as caldav server.

When I create a calendar entry on the phone (Android 4.4.2) the correct time is also displayed in Owncloud. When I change that event (e.g. the title) in Owncloud, the updated event is sent to the phone with a time of 2 hours later.

In the log I see: TimezoneUtil::getMSTZnameFromTZName() no MS name found for 'Europe/Berlin'. Returning '(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London'

The XML Debug is in the attachment. The true time from this entry is 14:30-15:30. My phone displays 16:30-17:30

Any ideas ?

Meitonga

meitonga commented 9 years ago

Hmm, i cannot upload files.

So here is the debug output: BackendCalDAV->_ParseVEventToAS(): Parsing VEvent TimezoneUtil::getMSTZnameFromTZName() no MS name found for 'Europe/Berlin'. Returning '(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London' TimezoneUtil::getMSTZnameFromTZName() no MS name found for 'Europe/Berlin'. Returning '(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London' BackendCalDAV->_ParseVEventToSyncObject(): 'X-MICROSOFT-CDO-ALLDAYEVENT' is not yet supported. O O O O 20151011T134025Z-09c7446187212dbe12c40be0a312aba9.ics O O O POOMCAL:Timezone O xP///0NFVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAEAAAAAAAAAAAAAAENFU1QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAEAAAAAAAAAxP///w== O /POOMCAL:Timezone O POOMCAL:DtStamp O 20151011T142347Z O /POOMCAL:DtStamp O POOMCAL:StartTime O 20151012T143000Z O /POOMCAL:StartTime O POOMCAL:Subject O 14301 O /POOMCAL:Subject O POOMCAL:UID O 20151011T134025Z-09c7446187212dbe12c40be0a312aba9 O /POOMCAL:UID O POOMCAL:OrganizerEmail O user@yyy.zzz O /POOMCAL:OrganizerEmail O POOMCAL:EndTime O 20151012T153000Z O /POOMCAL:EndTime O POOMCAL:Sensitivity O 0 O /POOMCAL:Sensitivity O POOMCAL:BusyStatus O 2 O /POOMCAL:BusyStatus O O O

Santiago-x commented 9 years ago

Hello meitonga,

I had the same problem.

The following quick fix solved it for me. But I'm not a contributer of this project, so this has to be checked again.

File: lib/utils/TimezoneUtils.php

static public function getMSTZnameFromTZName($name) {
    foreach (self::$mstzones as $mskey => $msdefs) {
        if ($name == $msdefs[0])
            return $msdefs[1];
    }

   // These lines were added
    $servertzname = self::guessTZNameFromPHPName($name);
    return self::GetFullTZFromTZName($servertzname);

    // ZLog::Write(LOGLEVEL_WARN, sprintf("TimezoneUtil::getMSTZnameFromTZName() no MS name found for '%s'. Returning '(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London'", $name));
    //return self::$mstzones["085"][1];
}
meitonga commented 9 years ago

Hello Santiago-x,

thanks for the reply, that solved it for me !!

Can some coder look into the change ?

tiiiecherle commented 9 years ago

Hey Santiago-x,

thanks a lot, the commit fixed the issue for me, too.

Will it keep working with summer and winter time in the respective timezone?

Santiago-x commented 9 years ago

Hello tiiiecherle,

it should work with summer and winter time. Unfortunately, I'm not able to test it because my phone has a bug in the calender app :(

Any help would be appreciated.

tiiiecherle commented 9 years ago

Hey Santiago-x,

thanks, I´ll try it out when possible.

fmbiete commented 8 years ago

@Santiago-x could you make a merge request so I can push your change? If it's not possible I will add it as an independent commit.

Thanks!!

tboerner commented 8 years ago

Possibly related issue: CalDAV backend is Owncloud here, sync'ing with iDevices. Sync'ing appointments works fine from iDevice to Owncloud calender. From Owncloud to iDevice works fine in winter, however in DST period appointments show up on iDevice 1h too late. After some investigation I found that there is something going wrong in caldav.php, line 609 (function _ParseVEventToSyncObject() ): $message->starttime = Utils::MakeUTCDate($property->Value(), Utils::ParseTimezone($property->GetParameterValue("TZID"))); At least with Owncloud $property->GetParameterValue("TZID") returns a timezone in the format like "Europe/Berlin". ParseTimezone() converts it into MS format "(GMT+01:00) Amsterdam..." (is this intended?), but MakeUTCDate() expects "Europe/Berlin". With MS format it still returns a generic +1 timezone, but the DST information is lost. I patched it for my specific case by changing line 609 to: $message->starttime = Utils::MakeUTCDate($property->Value(), $property->GetParameterValue("TZID")); // do not call ParseTimezone() In my case, MakeUTCDate() now always returns the correct UTC date, but this may not be a general solution for other CalDAV servers. Perhaps it would be better to rework ParseTimezone() accordingly instead. I am not aware what side effects this may cause, so I preferred not to change anything there.

Santiago-x commented 8 years ago

Hi tboerner,

thank you for your feedback! I also checked it and I totally agree with you. Therefore I will provide a new patch for this issue in a few minutes.

I also reflected my workaround and will provide a "better" solution which fits better to the improvements made by croessler #260

tboerner commented 8 years ago

Hi Santiago-x, thanks for your feedback - and the patch!