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, PCL
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>, IZoneIntervalMap
Constructors
DateTimeZone(String, Boolean, Offset, Offset)
Since 1.4.x
Availability net35-Client, PCL
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, PCL
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, PCL
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, PCL
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
e.g. DateTimeZoneProviders.Tzdb["UTC"]
.
Since 1.4.x
Availability net35-Client, PCL
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, PCL
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, PCL
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, PCL
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.4.x
Availability net35-Client, PCL
Declaration
[Obsolete("General DateTimeZone equality is not supported in 2.0")]
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.4.x
Availability net35-Client, PCL
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.4.x
Availability net35-Client, PCL
Declaration
[Obsolete("General DateTimeZone equality is not supported in 2.0")]
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, PCL
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.4.x
Availability net35-Client, PCL
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, PCL
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 (with the same split between standard time and daylight saving time, and with the same offset).
Since 1.4.x
Availability net35-Client, PCL
Declaration
public abstract ZoneInterval GetZoneInterval(Instant instant)
Parameters
Returns
See Also
GetZoneIntervals(Instant, Instant)
Returns all the zone intervals which occur for any instant in the interval [start
, end
).
Since 1.4.x
Availability net35-Client, PCL
Declaration
public IEnumerable<ZoneInterval> GetZoneIntervals(Instant start, Instant end)
Parameters
Type |
Name |
Description |
Instant |
start |
Inclusive start point of the interval for which to retrieve zone intervals. |
Instant |
end |
Exclusive end point of the interval for which to retrieve zone intervals. |
Returns
Type |
Description |
IEnumerable<ZoneInterval> |
A sequence of zone intervals covering the given interval. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
end is earlier than start . |
See Also
GetZoneIntervals(Interval)
Returns all the zone intervals which occur for any instant in the given interval.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public IEnumerable<ZoneInterval> GetZoneIntervals(Interval interval)
Parameters
Type |
Name |
Description |
Interval |
interval |
Interval to find zone intervals for. |
Returns
Type |
Description |
IEnumerable<ZoneInterval> |
A sequence of zone intervals covering the given interval. |
See Also
MapLocal(LocalDateTime)
Returns complete information about how the given
LocalDateTime is mapped in this time zone.
Since 1.4.x
Availability net35-Client, PCL
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, PCL
Declaration
public ZonedDateTime ResolveLocal(LocalDateTime localDateTime, ZoneLocalMappingResolver resolver)
Parameters
Returns
Type |
Description |
ZonedDateTime |
The result of resolving the mapping. |
Exceptions
Type |
Condition |
ArgumentNullException |
resolver is null. |
ToString()
Returns the ID of this time zone.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public override string ToString()
Returns
Type |
Description |
String |
The ID of this time zone.
|
Overrides
System.Object.ToString()
Implements
System.IEquatable<T>