1

I'm using the /me/mailboxSettings/timeZone Graph API to get a user's timezone information.

In attempt to figure out the expected return result format, I came across this documentation:

https://learn.microsoft.com/en-us/graph/api/resources/datetimetimezone?view=graph-rest-1.0

So it seems MS Graph's supported timezones are a mixture of Windows and IANA timezones.

But there is no doc that mentions what kind of timezone one should expect when calling the /me/mailboxSettings/timeZone API.

Does this mean I should expect to encounter both IANA and Windows timezones when calling this API?

If that is the case, is there a quick method to use this info to get the current UTC offset from the timezone, when the timezone could be in either Windows or IANA format at runtime?

thankyoussd
  • 1,875
  • 1
  • 18
  • 39

1 Answers1

4

From the documentation on get mailbox settings graph will support both IANA and Windows Timezones depending on the mailbox configuration. There are some questions on how to convert between IANA and Windows timezones see how-to-translate-between-windows-and-iana-time-zones - then you can use TimeZoneInfo to get the GetUtcOffset method.

I hope this helps,

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
Diana
  • 690
  • 6
  • 14
  • These random feature requests will go nowhere. I'm not expecting the Graph API to return the offset, rather it will need to get done via some C#/.NET library. – thankyoussd May 03 '21 at 06:41
  • Thank you for the feedback, I have updated the answer with more relevant info. – Diana May 03 '21 at 10:48
  • Thanks. Since I won't know ahead of the time if the `timeZone` MS Graph returns is Windows or IANA, do I simply do something like looking for the "/" character in the string and if yes it's IANA, or compare the string against the full list of Windows/IANA timezone DB?? It feels a bit hacky for me, unless there's a library out there that can detect the timezone type do the conversion for both. – thankyoussd May 03 '21 at 13:49
  • 3
    You can use the TimeZoneConverter library mentioned in the link in this answer. Its `GetTimeZoneInfo` method will take either form. But also, don't use `BaseUtcOffset`, but rather `GetUtcOffset`. – Matt Johnson-Pint May 03 '21 at 15:31