2
votes

I am trying to create one-day, all-day events with the Outlook 365 API. To do so, I specify the Start and End time in UTC format, and then indicate the StartTimeZone and EndTimeZone as described by the documentation:

{
  Start: '2015-07-14T23:00:00.000Z',
  End: '2015-07-15T23:00:00.000Z',
  StartTimeZone: 'W. Central Africa Standard Time',
  EndTimeZone: 'W. Central Africa Standard Time',
  ShowAs: 'Free',
  IsAllDay: true,
  Body: {
    ContentType: 'HTML',
    Content: '<a href="http://localhost:3000/todos/MDckAk8b2nxvv4hoE">To-do due date</a>'
  },
  Subject : 'test 74'
}

Now, here are my problems:

  • Using a string to define the timezone is inconvenient and inconsistent. London uses GMT during winter, but GMT+1 during summer. As a result I must use 'W. Central Africa Standard Time' during summer to have my request accepted by the API, which is confusing. Defining the time merely with this format, with no mention of a timezone: 2015-07-14T00:00:00+/-XX:00 to describe midnight, the beginning of July 14th in a zone where the time is GMT+/-XX:00 would be unequivocal and ideal to me, but this date format is rejected by the API with the option IsAllDay: true, stating that an all-day event should start and end at midnight (if no StartTimeZone and EndTimeZone is given).

  • Some time zone simply do not work with the GMT offset given in the doc, even when the time and the zone correspond. Those zone simply do not work with their GMT offset: Alaskan Standard Time, Pacific Standard Time, Mid-Atlantic Standard Time. Here is a query example that fails ('Mid-Atlantic Standard Time', GMT offset of -2):

    { Start: '2015-07-15T02:00:00.000Z', End: '2015-07-16T02:00:00.000Z', StartTimeZone: 'Mid-Atlantic Standard Time', EndTimeZone: 'Mid-Atlantic Standard Time', ShowAs: 'Free', IsAllDay: true, Body: { ContentType: 'HTML', Content: 'To-do due date' }, Subject : 'test 75' } It works with a GMT offset of -1 (Start: '2015-07-15T01:00:00.000'). How do I do for my users in GMT-2 ?

  • The same GMT offset can be described by several strings in the doc. For instance, 'Mountain Standard Time' and 'US Mountain Standard Time' both describe GMT-07:00, yet only my queries with 'US Mountain Standard Time' work. Some time offset can have up to 5 different strings! (like GMT+01:00) Which one to chose?

For now, I am choosing a TimeZone string that works (if one exists!) based on the GMT offset. If I set my clock at London current time, I will use 'W. Central Africa Standard Time' for StartTimeZone and EndTimeZone.

Is there a way NOT to use those strings? Or can someone explain me how to choose them right? I am completely lost in date translation! :)

2

2 Answers

1
votes

Getting all-day events right really does require knowing the user's time zone. Unfortunately if you create it in a random time zone, and the user mail client (Outlook, OWA, etc) uses another, the event will show up spanning multiple days (since the start and end get shifted from midnight).

So what you really should do here is set the start and end times with midnight in the user's time zone:

{
  "Start": "2015-07-17T00:00:00-04:00",
  "End": "2015-07-18T00:00:00-04:00",
  "StartTimeZone": "Eastern Standard Time",
  "EndTimeZone": "Eastern Standard Time",
  "IsAllDay": "true",
  "ShowAs": "Free",
  "Body": {
    "ContentType": "Text",
    "Content": "Test"
  },
  "Subject": "TZ AllDay Test"
}
0
votes

Where would the event be used? Use that local time zone.