Class DateTimeZone
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.
Since 1.4.x
Availability net35-Client
Inheritance
Object
DateTimeZone
Inherited Members
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Assembly: NodaTime.dll
Syntax
public abstract class DateTimeZone : IEquatable<DateTimeZone>
Constructors
DateTimeZone(String, Boolean, Offset, Offset)
Since 1.4.x
Availability net35-Client
Declaration
protected DateTimeZone(string id, bool isFixed, Offset minOffset, Offset maxOffset)
Parameters
Type |
Name |
Description |
String |
id |
The unique id of this time zone. |
Boolean |
isFixed |
Set to true if this time zone has no transitions. |
Offset |
minOffset |
Minimum offset applied within this zone |
Offset |
maxOffset |
Maximum offset applied within this zone |
Properties
Id
The provider's ID for the time zone.
Since 1.4.x
Availability net35-Client
Declaration
public string Id { get; }
Property Value
MaxOffset
Returns the greatest (most positive) offset within this time zone, over all time.
Since 1.4.x
Availability net35-Client
Declaration
public Offset MaxOffset { get; }
Property Value
MinOffset
Returns the least (most negative) offset within this time zone, over all time.
Since 1.4.x
Availability net35-Client
Declaration
public Offset MinOffset { get; }
Property Value
Utc
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
DateTimeZoneProviders.Default["UTC"]
; that depends on whether the default provider has its own
mapping for that ID.
Since 1.4.x
Availability net35-Client
Declaration
public static DateTimeZone Utc { get; }
Property Value
Methods
AtLeniently(LocalDateTime)
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".
Since 1.4.x
Availability net35-Client
Declaration
public ZonedDateTime AtLeniently(LocalDateTime localDateTime)
Parameters
Type |
Name |
Description |
LocalDateTime |
localDateTime |
The local date/time to map. |
Returns
Type |
Description |
ZonedDateTime |
The unambiguous mapping if there is one, the later result if the mapping is ambiguous,
or the start of the later zone interval if the given local date/time is skipped. |
AtStartOfDay(LocalDate)
Returns the earliest valid
ZonedDateTime with the given local date.
Since 1.4.x
Availability net35-Client
Declaration
public ZonedDateTime AtStartOfDay(LocalDate date)
Parameters
Type |
Name |
Description |
LocalDate |
date |
The local date to map in this time zone. |
Returns
Exceptions
Type |
Condition |
SkippedTimeException |
The entire day was skipped due to a very large time zone transition.
(This is extremely rare.) |
AtStrictly(LocalDateTime)
Since 1.4.x
Availability net35-Client
Declaration
public ZonedDateTime AtStrictly(LocalDateTime localDateTime)
Parameters
Type |
Name |
Description |
LocalDateTime |
localDateTime |
The local date and time to map into this time zone. |
Returns
Exceptions
Equals(DateTimeZone)
Determines whether the specified
DateTimeZone is equal to this instance.
Since 1.2.x
Availability net35-Client
Declaration
public bool Equals(DateTimeZone obj)
Parameters
Returns
Type |
Description |
Boolean |
true if the specified DateTimeZone is equal to this instance;
otherwise, false .
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
Since 1.2.x
Availability net35-Client
Declaration
public override sealed bool Equals(object obj)
Parameters
Type |
Name |
Description |
Object |
obj |
The System.Object to compare with this instance. |
Returns
Type |
Description |
Boolean |
true if the specified System.Object is equal to this instance;
otherwise, false .
|
Overrides
System.Object.Equals(System.Object)
EqualsImpl(DateTimeZone)
Implements equality in derived classes.
Since 1.2.x
Availability net35-Client
Declaration
protected abstract bool EqualsImpl(DateTimeZone zone)
Parameters
Type |
Name |
Description |
DateTimeZone |
zone |
The zone to compare with this one. This is guaranteed (when called by Equals(DateTimeZone)) to
be a non-null reference of the same type as this instance. |
Returns
Type |
Description |
Boolean |
true if the specified DateTimeZone is equal to this instance;
otherwise, false .
|
ForOffset(Offset)
Returns a fixed time zone with the given offset.
Since 1.4.x
Availability net35-Client
Declaration
public static DateTimeZone ForOffset(Offset offset)
Parameters
Type |
Name |
Description |
Offset |
offset |
The offset for the returned time zone |
Returns
Type |
Description |
DateTimeZone |
A fixed time zone with the given offset. |
GetHashCode()
Returns a hash code for this instance.
Since 1.2.x
Availability net35-Client
Declaration
public abstract override int GetHashCode()
Returns
Type |
Description |
Int32 |
A hash code for this instance, suitable for use in hashing algorithms and data
structures like a hash table.
|
Overrides
System.Object.GetHashCode()
GetUtcOffset(Instant)
Returns the offset from UTC, where a positive duration indicates that local time is
later than UTC. In other words, local time = UTC + offset.
Since 1.4.x
Availability net35-Client
Declaration
public virtual Offset GetUtcOffset(Instant instant)
Parameters
Type |
Name |
Description |
Instant |
instant |
The instant for which to calculate the offset. |
Returns
Type |
Description |
Offset |
The offset from UTC at the specified instant.
|
GetZoneInterval(Instant)
Gets the zone interval for the given instant; the range of time around the instant in which the same Offset
applies.
Since 1.4.x
Availability net35-Client
Declaration
public abstract ZoneInterval GetZoneInterval(Instant instant)
Parameters
Returns
MapLocal(LocalDateTime)
Returns complete information about how the given
LocalDateTime is mapped in this time zone.
Since 1.4.x
Availability net35-Client
Declaration
public ZoneLocalMapping MapLocal(LocalDateTime localDateTime)
Parameters
Type |
Name |
Description |
LocalDateTime |
localDateTime |
The local date and time to map in this time zone. |
Returns
Type |
Description |
ZoneLocalMapping |
A mapping of the given local date and time to zero, one or two zoned date/time values. |
ResolveLocal(LocalDateTime, ZoneLocalMappingResolver)
Since 1.4.x
Availability net35-Client
Declaration
public ZonedDateTime ResolveLocal(LocalDateTime localDateTime, ZoneLocalMappingResolver resolver)
Parameters
Returns
Type |
Description |
ZonedDateTime |
The result of resolving the mapping. |
Exceptions
Type |
Condition |
System.ArgumentNullException |
resolver is null |
ToString()
Returns the ID of this time zone.
Since 1.4.x
Availability net35-Client
Declaration
public override string ToString()
Returns
Type |
Description |
String |
The ID of this time zone.
|
Overrides
System.Object.ToString()
Implements
System.IEquatable<T>