Tag Archives: daylight saving

Google Calendar, Timezones and daylight saving

I’m fully aware of how complicated and dangerous working with timezones can be, especially if recurring events and daylight saving are involved.

Outsourcing calendar event creation

So when I decided that I wanted my kids school timetables in ics format and that I’d ‘outsource’ the manual data entry of it, I took great care to setup the calendars myself, specifying the Australia/Sydney Timezone.     I found a great person on elance based in the states who was knowledgeable about google calendar and recurring events.  I shared the time table calendars with her.  She set up the events in the two timetables. I checked it and all was good for a few weeks.

Then the normal Sydney (NSW) daylight saving period ended.

And NOW all the timetable events were TWO hours out – yes two (2) ?? why?

Being knowledgeable in these matters and having done SO many tests with timezones changing daylight saving at different overlapping times etc, I knew that it must be something to do with timezones.  I logged on to google and could not find anything online that told me anything.  Timetable calendars still set to Sydney, but all the events now mysteriously 2 hours out.

Troubleshooting google calendar – check the ics file

I downloaded the ics file to see if that would shed any light.    The ics file had a timezone definition for Australia/Sydney AND for America/New_York and ALL the class events were defined with timezone America/New_York.

Now google very clearly says that it stores the events in UTC / GMT time.

So why export events for a timezone OTHER than

  • either UTC or the
  • calendars timezone or
  • the accounts timezone?

why not just one hour out?     Had I missed the New York daylight saving change on 9 Mar?  Maybe ?   The times are just of the hour like 10.50 instead of 8.50 – maybe when I saw 9.50 I just thought 9 ?  who knows?

How to avoid unintended timezone daylight saving clashes happening again ?

Well I’m guessing – it appears google will use the timezone of the person creating the event EVEN if the calendar is in a different timezone AND this timezone is NOT shown when one looks at the event, NOT even in event debug / troubleshooting mode (add &eventdeb=1 to your google calendar url).

The creator has to manually assign a timezone to each and every event to ensure that it gets exported correctly.

 How to fix the current timetables offset by two hours?

I didn’t want to delete the existing calendars and Google allows no other easy way to delete events from any non-main calendar other than deleting the whole calendar.

I decided  a temporary fix (until the next daylight change !)  would be to export to ics, do a global change to a timezone 2 hours before New_York (hopefully one with out daylight saving – sadly I gave up on that)

I created a test calendar and did several iterations to check the timings. I ended up using http://gcaltoolkit.net/ to handle bulk deletes of the calendars and learnt a few things along the way:

For example: Even if you have deleted the events and want to re-import them, google will not let you.  To fox it – do a gloabl change on the @google.com of the UID .  Events are identified by UID.

At one stage I even felt I needed to change the file name and calendar name, but perhaps I was just tired, confused and annoyed by then.

Summary:

  1. BACKUP all your google calendars and possibly other data first before letting another app mess with your data.  Create a TEST calendar to test the whole process.
  2. Export your ics files, create a backup copy.
  3. Use something like notepad++ to do a search/replace on the timezone.  Make sure your new timezone is something google will recognise and the correct UTC offset.
  4. Search and replace the @google.com to @yourdomain.com or really anything…(alter the event UID globally every time you re-import the file.)
  5. Save and close the ics file.
  6. Use gcaltoolkit or similar to delete the events in your target calendar (very carefully check which calendar you are accessing)
  7. Make a cup of tea – ieWait a few minutes, sometimes it takes google a while to update.
  8. Import the ics file and check the times.

 

 

 

Problem with Dates/Time – Off by 1 Hour?

If you are using amr-events or amr-ical-events-list you will not have this problem!

Every time a zone somewhere in the world kicks on to daylight saving or off for that matter, I see a bunch of support questions popping up about their event times being off by an hour.    (I monitor wordpress support, stackexchange and wpquestions, and maybe a few more…..)

From a favourite cartoon source - thanks http://xkcd.com/673/

Imagine the confusion this can cause where clients may have subscribed to calendar feeds and have the wrong times.

PHP datetime objects and functions

If people are very lucky, the plugin that they are using has some good coding and is using php DateTime objects with timezone support, and the only problem is that their wordpress timezone is set as a GMT offset, not as a timezone.

That is easily fixed! (goto wordpress general settings)

However all too often the plugin developer has failed to appreciate

  • the complexities of times around the world,
  • timezones,
  • daylight saving and
  • most importance of managing recurring events in one timezone for a display in another where one zone changes daylight saving.  Very easy to generate the wrong times for a recurring event without realising it!
  • even worse governments sometimes change the date/time of the switchover (ok not that often, but it does happen, and then you hope your php installation gets updated with the timezone definitions)

Fixes:

If it is not a simple wordpress timezone setting, then these things are NOT easy to fix and will involve changes to code:

  1. Change to use php DateTime Classes for all date logic .If they are using unix time and not  php datetime objects, it is almost impossible to get it right.  It’s a fairly major rewrite to change all date logic to use the DateTime objects and functions.
  2. If already using, it maybe that the intricacies of recurring event logic have won out.  See below for logic help.

Developers and event website managers should read: