[This is preliminary documentation and is subject to change.]

C# | Visual Basic | Visual C++ |
DateTimeZone GetSystemDefault()
Function GetSystemDefault As DateTimeZone
DateTimeZone^ GetSystemDefault()


Callers should be aware that this method will throw DateTimeZoneNotFoundException if no matching time zone is found. For the built-in Noda Time providers, this is unlikely to occur in practice (assuming the system is using a standard Windows time zone), but can occur even then, if no mapping is found. The TZDB source contains mappings for almost all Windows system time zones, but a few (such as "Mid-Atlantic Standard Time") are unmappable.
If it is necessary to handle this case, callers can construct a BclDateTimeZone via ForSystemDefault()()()(), which returns a DateTimeZone that wraps the system local TimeZoneInfo, and which always succeeds. Note that BclDateTimeZone is not available on the PCL build of Noda Time, so this fallback strategy can only be used with the desktop version.

Exception | Condition |
---|---|
DateTimeZoneNotFoundException | The system default time zone is not mapped by
this provider. |
Assembly: NodaTime (Module: NodaTime.dll) Version: 1.2.0.0 (1.2.0)