3

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! :)

qnilab
  • 380
  • 3
  • 18

2 Answers2

2

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"
}
Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • Hi Jason, thanks for your answer. What you suggest is exactly what I do, if I am not mistaken, your time format is just different, but it yields the exact same result. What I do is that I call getTimeZoneOffset and chose one of the timezones that matches this offset (so, I do not chose a random time zone), but this does not seem great. Really, Microsoft has a confusing doc when they write that London lives at GMT, this is only true part of the year, now it lives at W. Central Africa Standard Time, which is true but kind of dumb... – qnilab Jul 15 '15 at 16:07
0

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

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Hi Dmitry, we are using the REST API from our app, that works in a browser. Our app is likely to be used anywhere in the world, so we have to support any location, or as many as possible. How can I get the local time zone -the very one compatible with the API- from the browser? Right now I am calling the getTimeZoneOffset method of the javascript Date object and associate a random time zone among the ones that work, but this is weak, since the function that associates a timezone to an offset is surjective... – qnilab Jul 14 '15 at 23:24
  • I don't think you can do that in JavaScript - http://stackoverflow.com/questions/18246547/get-name-of-time-zone – Dmitry Streblechenko Jul 15 '15 at 00:54
  • Hi Dmitry, this is very unfortunate. So, there is no way not to use those confusing strings? – qnilab Jul 15 '15 at 16:08