View Issue Details

IDProjectCategoryView StatusLast Update
0002686SOGoActiveSyncpublic2014-04-02 18:15
Reportertfu Assigned Toludovic  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platform[Client] MicrosoftOSWindowsOS Version7
Product Version2.2.2 
Fixed in Version2.2.3 
Summary0002686: all day events are not handled correctly
Description

The timezone handling of allday events are not correct.
-> an allday event entered on server spans 2 days when synced to the client.
-> an allday event entered on client is put to the wrong day on the server.

Steps To Reproduce

Enter an allday event via web ui (tz in user pref: europe/vienna)
Sync the event via activesync (client's tz is also set to europe/vienna)

-> The event on client spans 2 days starting von 01:00.


Enter an allday event on a client
sync the event via activesync

-> The event on the server is on the wrong day.

TagsNo tags attached.

Activities

tfu

tfu

2014-03-26 16:38

reporter  

0001-all-day-events.patch (3,558 bytes)   
From 04a444094c3df48f19e0f728bf0ae333ee65da3d Mon Sep 17 00:00:00 2001
From: root <root@example.com>
Date: Wed, 26 Mar 2014 21:22:23 +0100
Subject: [PATCH] all day events

---
 ActiveSync/iCalEvent+ActiveSync.m |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/ActiveSync/iCalEvent+ActiveSync.m b/ActiveSync/iCalEvent+ActiveSync.m
index 05f18a3..1eeeb20 100644
--- a/ActiveSync/iCalEvent+ActiveSync.m
+++ b/ActiveSync/iCalEvent+ActiveSync.m
@@ -83,6 +83,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
   int v;
 
+  NSTimeZone *userTimeZone;
+  userTimeZone = [[[context activeUser] userDefaults] timeZone];
+
   s = [NSMutableString string];
   
   [s appendFormat: @"<AllDayEvent xmlns=\"Calendar:\">%d</AllDayEvent>", ([self isAllDay] ? 1 : 0)];
@@ -95,17 +98,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   // StartTime -- http://msdn.microsoft.com/en-us/library/ee157132(v=exchg.80).aspx
   if ([self startDate])
-    [s appendFormat: @"<StartTime xmlns=\"Calendar:\">%@</StartTime>", [[self startDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
-  
+     [self isAllDay]
+          ? [s appendFormat: @"<StartTime xmlns=\"Calendar:\">%@</StartTime>", [[[self startDate] dateByAddingYears: 0 months: 0 days: 0  hours: 0 minutes: 0 seconds:  ([userTimeZone secondsFromGMTForDate: [self startDate]])*-1] activeSyncRepresentationWithoutSeparatorsInContext: context]]
+          : [s appendFormat: @"<StartTime xmlns=\"Calendar:\">%@</StartTime>", [[self startDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
+
   // EndTime -- http://msdn.microsoft.com/en-us/library/ee157945(v=exchg.80).aspx
   if ([self endDate])
-    [s appendFormat: @"<EndTime xmlns=\"Calendar:\">%@</EndTime>", [[self endDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
-  
+     [self isAllDay]
+          ? [s appendFormat: @"<EndTime xmlns=\"Calendar:\">%@</EndTime>", [[[self endDate] dateByAddingYears: 0 months: 0 days: 0  hours: 0 minutes: 0 seconds:  ([userTimeZone secondsFromGMTForDate: [self endDate]])*-1] activeSyncRepresentationWithoutSeparatorsInContext: context]]
+          : [s appendFormat: @"<EndTime xmlns=\"Calendar:\">%@</EndTime>", [[self endDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
+
   // Timezone
   tz = [(iCalDateTime *)[self firstChildWithTag: @"dtstart"] timeZone];
 
   if (!tz)
-    tz = [iCalTimeZone timeZoneForName: @"Europe/London"];
+    tz = [iCalTimeZone timeZoneForName: [userTimeZone timeZoneName]];
 
   [s appendFormat: @"<TimeZone xmlns=\"Calendar:\">%@</TimeZone>", [tz activeSyncRepresentationInContext: context]];
   
@@ -356,6 +363,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
       if (isAllDay)
         {
+          tzOffset = [userTimeZone secondsFromGMTForDate: o];
+          o = [o dateByAddingYears: 0 months: 0 days: 0
+                             hours: 0 minutes: 0
+                           seconds: tzOffset];
           [start setDate: o];
           [start setTimeZone: nil];
         }
@@ -377,6 +388,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
       if (isAllDay)
         {
+          tzOffset = [userTimeZone secondsFromGMTForDate: o];
+          o = [o dateByAddingYears: 0 months: 0 days: 0
+                             hours: 0 minutes: 0
+                           seconds: tzOffset];
           [end setDate: o];
           [end setTimeZone: nil];
         }
-- 
1.7.9.5

0001-all-day-events.patch (3,558 bytes)   
tfu

tfu

2014-03-26 16:38

reporter   ~0006784

The attached patch should give an idea what's wrong.

ludovic

ludovic

2014-03-28 14:59

administrator   ~0006804

I'm not sure about the change below:

if (!tz)

  • tz = [iCalTimeZone timeZoneForName: @"Europe/London"];
  • tz = [iCalTimeZone timeZoneForName: [userTimeZone timeZoneName]];

If no timezone is linked to the DTSTART, that usually means the event is relative to GMT (ending with Z).

Of couse, the event could be in the localtime, no Z, no timezone. We should handle that.

tfu

tfu

2014-03-29 17:29

reporter   ~0006809

You are right the change is not needed and allday events work without it.

There migth still a problem with allday events if the device is set to a different tz then that was used to covert the start/endtime to GMT before syncing. If the server doens't know the tz on the client it is not possible to convert the start/end time to the right time which would give 00:00 on the client after it is converted to client's tz. -> no 00:00 -> no allday event.

ludovic

ludovic

2014-04-02 18:15

administrator   ~0006819

Fix pushed: https://github.com/inverse-inc/sogo/commit/078b88a396b3839880e6cc3638e5d2f6307c670c

Let's track the potential tz issue in an other bug.

Thanks for your patches, keep them coming, you're doing a great job!

Issue History

Date Modified Username Field Change
2014-03-26 16:37 tfu New Issue
2014-03-26 16:38 tfu File Added: 0001-all-day-events.patch
2014-03-26 16:38 tfu Note Added: 0006784
2014-03-28 14:59 ludovic Note Added: 0006804
2014-03-29 17:29 tfu Note Added: 0006809
2014-04-02 18:15 ludovic Note Added: 0006819
2014-04-02 18:15 ludovic Status new => resolved
2014-04-02 18:15 ludovic Fixed in Version => 2.2.3
2014-04-02 18:15 ludovic Resolution open => fixed
2014-04-02 18:15 ludovic Assigned To => ludovic