[kronolith] Date and Timezones..

Michael J Rubinsky mrubinsk at horde.org
Mon Jan 9 21:12:36 UTC 2012


Quoting Simon Brereton <simon.brereton at buongiorno.com>:

> Hi
>
> I'm addressing this to Kronolith but for me it'a system-wide issue as
> it affects sync as well.
>
> The specific issue is that I have a user complaining about an error -
>
> DateTime::_construct(): Failed to parse time string (-001-11-01) at
> position 7 (-): Double timezone specificatio

These errors are _probably_ not related to timezones at all. They are  
usually due to some non-standard or malformed datetime string being  
passed to DateTime's constructor (and it mistakes part of the string  
for a timezone specifier). Where do you see this? Creating an event  
from which interface?  If you can get a look at exactly where in the  
code and what the value is, we can try to help.

> when trying to create an appointment.
>
> More generally time zones are an issue that I can't get right.
> Hopefully you can advise me how to fix this.
>
> The server is set to UTC. Most of the users are either UTC+1, GMT or
> UTC-5.  What happens for the UTC-5 users (i.e. me) is that if I create
> an all-day appointment or mark a contact with the a birthday), the
> time is stored in UTC.  When this syncs to my device with activesync,
> it shows up at 7pm on the preceding day even though in my Horde
> Preferences I have my time-zone set to America/New York (i.e. UTC-5).
> If I then go into the device and edit the time-zone to be EST then
> when I log back into Horde, the appointment is now pushed over into a
> second day.  I illustrate with a real-world numbers example...
>
> I have a contact with a birthday on the 11th of January.  In Horde, I
> create the all-day appointment on the 11th (repeating yearly, etc).
> The phone shows the appointment as starting on the 10th at 7pm (even
> though it's all-day - i.e. it shows up at the top of both the 10th and
> the 11th and I get the reminder (set to 5 minutes) at 6.55pm EST).  If
> I then edit the appointment to be EST on the device this makes the
> appointment correctly show up on the device only on the 11th (with the
> reminder at 11.55pm on the 10th) but when I log into Horde the
> appointment is now showing from the 11/01/2012 to 12/01/2012 and
> appears in both days.
>
> Similarly the GMT and UTC+1 users have the reverse problem...
>
> They create the appointment but then appointment reminder is either
> late or the appointment shows on the day AFTER.  If they edit it on
> the device to be GMT (or UTC+1) then the appointment shows correctly
> on the device but when they go back to Horde the appointment is now
> showing on day before in Horde.
>
> To be clear, I don't think this is a Horde issue - I'm perfectly
> willing to believe I've set something up incorrectly, but I'd be
> grateful is someone could say what.
>
> Regular (i.e. 1 hour/12 hour/30 min) appointments don't have this issue.
> But if it isn't me, then I think the solution would be as in other
> PIMs to be able to set the time-zone for the appointments/contacts.

First of all, I will assume you are running a released version. The  
'develop' branch (which will be released as the x.1 releases) has the  
ability to set individual event's timezones. Though, in the examples  
you cite above, this feature really wouldn't help you. I am also going  
to assume that you have verified that all of your PEAR packages are up  
to date - espeically Horde_Date, Kronolith and Horde_ActiveSync. There  
were some not-so-long-ago fixes made related to datetime handling.

I'm not entirely sure what may be causing the issues you are seeing so  
I will describe how it is *supposed* to work and we can go from there.  
For support across timezones you *must* store your events as UTC in  
the database. Otherwise, the events are "floating" and will always  
appear at the same physical time regardless of timezone. Let's assume  
your timezone in Horde is set to America/New_York. You create an event  
in Horde. Internally, the event is converted to UTC time and stored in  
the database. When you sync the event via ActiveSync, it is the UTC  
value that is sent to the device, along with some timezone inforation.  
The TZ information that is sent from Horde is actually only used by  
the device if it is a recurring event that crosses a DST transition.  
Otherwise, the datetime is converted to the device's configured  
timezone. So, for example, an event created at 5:00PM in a UTC-5  
timezone would get stored in the database (and sent to the device) as  
10:00PM on the same day. The device receives this value and (assuming  
the device's timezone is set to UTC-5), converts it back to 5:00PM.   
In this scenerio it doesn't matter what timezone the physical server  
is set to. The important bits are the timezone prefs on both Horde and  
the device.

Now, that being said, seeing how your "1 hour/12 Hour/30min"  
appointments *do* come across correctly, it sounds like there might be  
an issue with either how your device handles all day events or there  
is a bug in how Horde handles these events.

I'm also unclear as to what is going on when you are setting the event  
to be UTC-5 on your device manually. You said your Horde prefs are  
UTC-5, right? So the event was converted from UTC-5 to UTC in Horde  
and then sent to the device. The device should convert this to it's  
configured timezone. Assuming your device is configured for the  
timezone you are in, it should have converted to UTC-5 on it's own. As  
explained above, the event is sent as UTC to the device and then  
converted to the device's timezone. It sounds to me as if the device  
either doesn't offer proper timezone support or the timezone is not  
set correctly. What timezone does the event show in prior to editing it?

-- 
mike

The Horde Project (www.horde.org)
mrubinsk at horde.org




More information about the kronolith mailing list