DateTimeZone ClassNoda Time
Represents a time zone - a mapping between UTC and local time. A time zone maps UTC instants to local times - or, equivalently, to the offset from UTC at any particular instant.
Inheritance Hierarchy

OnlineSystem Object
  NodaTime DateTimeZone
    NodaTime.Testing.TimeZones MultiTransitionDateTimeZone
    NodaTime.Testing.TimeZones SingleTransitionDateTimeZone
    NodaTime.TimeZones BclDateTimeZone

Namespace: NodaTime
Assembly: NodaTime (in NodaTime.dll) Version: 1.3.0.0 (1.3.1)
Syntax

public abstract class DateTimeZone : IEquatable<DateTimeZone>, 
	IZoneIntervalMap
Remarks

The mapping is unambiguous in the "UTC to local" direction, but the reverse is not true: when the offset changes, usually due to a Daylight Saving transition, the change either creates a gap (a period of local time which never occurs in the time zone) or an ambiguity (a period of local time which occurs twice in the time zone). Mapping back from local time to an instant requires consideration of how these problematic times will be handled.

Noda Time provides various options when mapping local time to a specific instant:

Noda Time has two built-in sources of time zone data available: a copy of the Onlinetz database (also known as the IANA Time Zone database, or zoneinfo or Olson database), and the ability to convert .NET's own OnlineTimeZoneInfo format into a "native" Noda Time zone. Which of these is most appropriate for you to use will very much depend on your exact needs. The zoneinfo database is widely used outside Windows, and has more historical data than the Windows-provided information, but if you need to interoperate with other Windows systems by specifying time zone IDs, you may wish to stick to the Windows time zones.

To obtain a DateTimeZone for a given timezone ID, use one of the methods on IDateTimeZoneProvider (and see DateTimeZoneProviders for access to the built-in providers). The UTC timezone is also available via the Utc property on this class.

To obtain a DateTimeZone representing the system default time zone, you can either call GetSystemDefault  on a provider to obtain the DateTimeZone that the provider considers matches the system default time zone, or you can construct a BclDateTimeZone via BclDateTimeZone.ForSystemDefault, which returns a DateTimeZone that wraps the system local OnlineTimeZoneInfo. The latter will always succeed, but has access only to that information available via the .NET time zone; the former may contain more complete data, but may (in uncommon cases) fail to find a matching DateTimeZone. 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.

Note that Noda Time does not require that DateTimeZone instances be singletons. As far as reasonably possible, implementations should implement OnlineIEquatable T  in such a way that equivalent time zones compare as equal.

Version Information

Available since: 1.0.0
Supported in the PCL? Yes
Thread Safety

All time zone implementations within Noda Time are immutable and thread-safe. See the thread safety section of the user guide for more information. It is expected that third party implementations will be immutable and thread-safe as well: code within Noda Time assumes that it can hand out time zones to any thread without any concerns. If you implement a non-thread-safe time zone, you will need to use it extremely carefully. We'd recommend that you avoid this if possible.
See Also