Open cocowalla opened 5 years ago
Not sure exactly what you mean exactly. Can you provide an example of what you'd expect?
TimeZoneConverter has a TZConvert.KnownWindowsTimeZoneIds
collection, if that's what you mean. Though it is always the current fully-up-to-date list. I don't track history of when the different time zones were made available (yet).
What I'm looking for is TZConvert.KnownWindowsTimeZoneIds
, but:
I assume you are referencing the format column in this Wikipedia page? One thing to keep in mind is that "deprecated" zones there really just mean that they aren't in the prefered area/locality format, so they should be generally removed from a pick-list. I assume that is your use case?
But that doesn't mean they don't work any more. In general, once a time zone id is introduced, it doesn't tend to go away. There has been one exception (Canada/East-Saskatchewan
discussed here), but I know of no others.
Also, I don't this status in these libraries presently. I will consider it for the future and leave this issue open to remind me, but I make no promises. Thanks.
Yes, this is basically for allowing users to select their timezone from a dropdown, and it seems prudent to prune the (rather large) list by removing ones that are no longer in use. Since GetTimeZonesForCountry
has a threshold parameter, I just assumed there was some simple way to do this for all timezones... other than calling GetLanguageCodes
and feeding the result into GetCountryNames
, then feeding the result of that into GetTimeZonesForCountry
:)
Oh, I'm sorry - I misunderstood. I see what you mean now.
Yes, today you can build this list like so:
var threshold = DateTimeOffset.Now;
var ids = TZNames.GetCountryNames("en").Keys
.SelectMany(code => TZNames.GetTimeZoneIdsForCountry(code, threshold))
.Concat(TZNames.GetFixedTimeZoneIds())
.Distinct()
.OrderBy(x => x);
And yes, I agree this should be built in as a simpler single function. Thanks for the suggestion.
I'm sure I'm missing something really obvious here, but is there a way to get a list of
TimeZoneInfo
s for all canonical IANA timezone IDs that are valid as of a given date?