qnilab
qnilab

Reputation: 474

Set up all-day calendar events with Outlook 365 API on different time zones

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:

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

Upvotes: 3

Views: 1212

Answers (2)

Jason Johnston
Jason Johnston

Reputation: 17702

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"
}

Upvotes: 2

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66255

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

Upvotes: 0

Related Questions