views:

26

answers:

2

I've always admired applications that, when asking you to indicate a timezone, only show you a set of likely options (in my case, only North American timezones), with an option to show more - rather than always forcing you to pick through dozens of obscure timezones.

Any thoughts how to go about this in .NET? My first thought was to define ranges of UTC offsets (e.g. -8 to -5 for the US) - but that includes zones in South America, etc. Should I just hard-code some arrays containing the TimeZoneInfo.ID values of likely sets of timezones for specific regions (e.g. North America, Europe, etc.)? Or is there a more elegant way?

+1  A: 

I guess the easiest way would be to just define the timezones that you were interested in, and not worry about auto populating them. Would end up being cleaner, and if some political figure changed a freaking time zone rule again (usually DST), you wont find something accidentally showing up in your list 3 years down the road.

TravisWhidden
+1  A: 

I don't think there's anything about the timezones as they are (from the .NET 3.5 TimeZoneInfo type) that would allow you to do such a regional restriction.

Of course, you could always establish such an "order" yourself and create a table that holds your regions (like "North America" or "Central Europe") and then just assign those time zones that match your regions to those.

But again: that would be 100% your own doing, there's nothing in .NET to help you with this, unfortunately. That's really "your thing" - not awfully hard to do, but totally up to you.

Marc

marc_s