I'm new to NodaTime & still finding my way around it.
If when I start my program the Android timezone is set to "America/New York"
NodaTime DateTimeZoneProviders.Tzdb.GetSystemDefault() correctly returns "America/New_York"
However if I then update the timezone via Android settings to "America/Denver" while my program is running, then DateTimeZoneProviders.Tzdb.GetSystemDefault() still returns "America/New_York"
How do I get the program to read the new Android System timezone & return that information?
I can't see any equivalent of TimeZoneInfo.ClearCachedData() and running that first makes no difference to NodaTime, although both TimeZoneInfo & DateTime.Now are correctly updated
TzdbDateTimeZoneSourcedoesn't do any caching - it fetchesTimeZoneInfo.Local.Idand maps that.So I would expect calling
TimeZoneInfo.ClearCachedData()to be sufficient, so long as that updatesTimeZoneInfo.Local.Id.In other words, if you run:
... I'd expect to see consistency, e.g. "America/New_York" twice and then "America/Denver" twice.
If you see "America/New_York" four times, that means
TimeZoneInfo.ClearCachedData()isn't actually updating the local time zone ID.If you see "America/New_York" twice, then "America/Denver", then "America/New_York", then that would be a bug in Noda Time - but assuming you're using a recent version, I can't easily see how that would happen. (
DateTimeZoneCachedoesn't cache the results ofGetSystemDefault(), nor doesTzdbDateTimeZoneSource.)