Jerry Nixon
Jerry Nixon

Reputation: 31831

List Time Zones in Windows 8 / WinRT / XAML apps?

It used to be that we would use TimeZoneInfo.GetSystemTimeZones() to enumerate time zones.

How do you do it in Windows 8 apps?

Upvotes: 4

Views: 1717

Answers (2)

Claire Novotny
Claire Novotny

Reputation: 1701

I've just blogged about how to do this and included the code you need as a gist.

Also, to address another commenter, no, ARM compatibility is not an issue as the marshaling happens correctly.

EDIT: just made it one better and turned it into a general purpose NuGet package:

https://nuget.org/packages/WinRTTimeZones

The source is here: https://github.com/onovotny/WinRTTimeZones

Upvotes: 5

Jim O'Neil
Jim O'Neil

Reputation: 23774

Per MSDN forums you'll have to roll your own approach, perhaps through a service that exposes the ICANN data?

Via PInvoke (EnumDynamicTimeZoneInformation) you could get a subset of them. And even with GetSystemTimeZones you wouldn't be guaranteed to get them all either (though I expect more than with the PInvoke).

Upvotes: 1

Related Questions