|C#||Visual Basic||Visual C++|
public abstract class DateTimeZone : IEquatable<DateTimeZone>, IZoneIntervalMap
Public MustInherit Class DateTimeZone Implements IEquatable(Of DateTimeZone), IZoneIntervalMap
public ref class DateTimeZone abstract : IEquatable<DateTimeZone^>, IZoneIntervalMap
|DateTimeZone(String, Boolean, Offset, Offset)|
Initializes a new instance of theclass.
Maps the given LocalDateTime to the corresponding ZonedDateTime in a lenient manner: ambiguous values map to the later of the alternatives, and "skipped" values map to the start of the zone interval after the "gap".
Returns the earliest valid ZonedDateTime with the given local date.
Maps the given LocalDateTime to the corresponding ZonedDateTime, if and only if that mapping is unambiguous in this time zone. Otherwise, SkippedTimeException or AmbiguousTimeException is thrown, depending on whether the mapping is ambiguous or the local date/time is skipped entirely.
Determines whether the specified Object is equal to this instance.(Overrides Object.Equals(Object).)
Determines whether the specifiedis equal to this instance.
Implements equality in derived classes.
Returns a fixed time zone with the given offset.
Returns a hash code for this instance.(Overrides Object.GetHashCode()()()().)
Returns the offset from UTC, where a positive duration indicates that local time is later than UTC. In other words, local time = UTC + offset.
Gets the zone interval for the given instant; the range of time around the instant in which the same Offset applies (with the same split between standard time and daylight saving time, and with the same offset).
Returns all the zone intervals which occur for any instant in the interval [start, end).
Returns all the zone intervals which occur for any instant in the given interval.
The provider's ID for the time zone.
Returns complete information about how the given LocalDateTime is mapped in this time zone.
Returns the greatest (most positive) offset within this time zone, over all time.
Returns the least (most negative) offset within this time zone, over all time.
Maps the given LocalDateTime to the corresponding ZonedDateTime, following the given ZoneLocalMappingResolver to handle ambiguity and skipped times.
Returns the ID of this time zone.(Overrides Object.ToString()()()().)
Gets the UTC (Coordinated Universal Time) time zone. This is a single instance which is not provider-specific; it is guaranteed to have the ID "UTC", but may or may not be the instance returned by e.g. DateTimeZoneProviders.Tzdb["UTC"].
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:
- AtStrictly(LocalDateTime) will throw an exception if the mapping from local time is either ambiguous or impossible, i.e. if there is anything other than one instant which maps to the given local time.
- AtLeniently(LocalDateTime) will never throw an exception due to ambiguous or skipped times, resolving to the later option of ambiguous matches or the start of the zone interval after the gap for skipped times.
- ResolveLocal(LocalDateTime, ZoneLocalMappingResolver) will apply a ZoneLocalMappingResolver to the result of a mapping.
- MapLocal(LocalDateTime) will return a ZoneLocalMapping with complete information about whether the given local time occurs zero times, once or twice. This is the most fine-grained approach, which is the fiddliest to use but puts the caller in the most control.
Noda Time has two built-in sources of time zone data available: a copy of the tz database (also known as the IANA Time Zone database, or zoneinfo or Olson database), and the ability to convert .NET's own TimeZoneInfo 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 GetSystemDefault()()()() on a provider to obtain the that the provider considers matches the system default time zone, or you can construct a BclDateTimeZone via BclDateTimeZone.ForSystemDefault, which returns a that wraps the system local TimeZoneInfo. 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 . 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.representing the system default time zone, you can either call
Note that Noda Time does not require that IEquatable<(Of <(<'T>)>)> in such a way that equivalent time zones compare as equal.instances be singletons. As far as reasonably possible, implementations should implement
Assembly: NodaTime (Module: NodaTime.dll) Version: 126.96.36.199 (1.2.0)