Noda Time
Show / Hide Table of Contents

Struct Offset

An offset from UTC in seconds. A positive value means that the local time is ahead of UTC (e.g. for Europe); a negative value means that the local time is behind UTC (e.g. for America).
Implements
IEquatable<Offset>
IComparable<Offset>
IFormattable
IComparable
IXmlSerializable
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
[TypeConverter(typeof(OffsetTypeConverter))]
public readonly struct Offset : IEquatable<Offset>, IComparable<Offset>, IFormattable, IComparable, IXmlSerializable
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Fields

MaxValue

The maximum permitted offset; 18 hours after UTC.
Declaration
public static readonly Offset MaxValue
Field Value
Type Description
Offset
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

MinValue

The minimum permitted offset; 18 hours before UTC.
Declaration
public static readonly Offset MinValue
Field Value
Type Description
Offset
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Zero

An offset of zero seconds - effectively the permanent offset for UTC.
Declaration
public static readonly Offset Zero
Field Value
Type Description
Offset
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Properties

Milliseconds

Gets the number of milliseconds represented by this offset, which may be negative.
Declaration
public int Milliseconds { get; }
Property Value
Type Description
int The number of milliseconds represented by this offset, which may be negative.
Remarks
Offsets are only accurate to second precision; the number of seconds is simply multiplied by 1,000 to give the number of milliseconds.

Nanoseconds

Gets the number of nanoseconds represented by this offset, which may be negative.
Declaration
public long Nanoseconds { get; }
Property Value
Type Description
long The number of nanoseconds.
Remarks
Offsets are only accurate to second precision; the number of seconds is simply multiplied by 1,000,000,000 to give the number of nanoseconds.

Seconds

Gets the number of seconds represented by this offset, which may be negative.
Declaration
public int Seconds { get; }
Property Value
Type Description
int The number of seconds represented by this offset, which may be negative.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Ticks

Gets the number of ticks represented by this offset, which may be negative.
Declaration
public long Ticks { get; }
Property Value
Type Description
long The number of ticks.
Remarks
Offsets are only accurate to second precision; the number of seconds is simply multiplied by 10,000,000 to give the number of ticks.

Methods

Add(Offset, Offset)

Adds one Offset to another. Friendly alternative to operator+().
Declaration
public static Offset Add(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
Offset A new Offset representing the sum of the given values.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

AddSchema(XmlSchemaSet)

Adds the XML schema type describing the structure of the Offset XML serialization to the given xmlSchemaSet.
Declaration
public static XmlQualifiedName AddSchema(XmlSchemaSet xmlSchemaSet)
Parameters
Type Name Description
XmlSchemaSet xmlSchemaSet The XML schema set provided by XmlSchemaExporter.
Returns
Type Description
XmlQualifiedName The qualified name of the schema type that was added to the xmlSchemaSet.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

CompareTo(Offset)

Compares the current object with another object of the same type. See the type documentation for a description of ordering semantics.
Declaration
public int CompareTo(Offset other)
Parameters
Type Name Description
Offset other An object to compare with this object.
Returns
Type Description
int A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings:
ValueMeaning
< 0This object is less than the other parameter.
0This object is equal to other.
> 0This object is greater than other.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Equals(Offset)

Indicates whether the current object is equal to another object of the same type. See the type documentation for a description of equality semantics.
Declaration
public bool Equals(Offset other)
Parameters
Type Name Description
Offset other An object to compare with this object.
Returns
Type Description
bool true if the current object is equal to the other parameter; otherwise, false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Equals(object?)

Determines whether the specified Object is equal to this instance. See the type documentation for a description of equality semantics.
Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj The Object to compare with this instance.
Returns
Type Description
bool true if the specified Object is equal to this instance; otherwise, false.
Overrides
ValueType.Equals(Object)
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

FromHours(int)

Returns an offset for the specified number of hours, which may be negative.
Declaration
public static Offset FromHours(int hours)
Parameters
Type Name Description
int hours The number of hours to represent in the new offset.
Returns
Type Description
Offset An offset representing the given value.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The specified number of hours is outside the range of [-18, +18].

FromHoursAndMinutes(int, int)

Returns an offset for the specified number of hours and minutes.
Declaration
public static Offset FromHoursAndMinutes(int hours, int minutes)
Parameters
Type Name Description
int hours The number of hours to represent in the new offset.
int minutes The number of minutes to represent in the new offset.
Returns
Type Description
Offset An offset representing the given value.
Remarks
The result simply takes the hours and minutes and converts each component into milliseconds separately. As a result, a negative offset should usually be obtained by making both arguments negative. For example, to obtain "three hours and ten minutes behind UTC" you might call Offset.FromHoursAndMinutes(-3, -10).
Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

FromMilliseconds(int)

Returns an offset for the given milliseconds value, which may be negative.
Declaration
public static Offset FromMilliseconds(int milliseconds)
Parameters
Type Name Description
int milliseconds The int milliseconds value.
Returns
Type Description
Offset An offset representing the given number of milliseconds, to the (truncated) second.
Remarks
Offsets are only accurate to second precision; the given number of milliseconds is simply divided by 1,000 to give the number of seconds - any remainder is truncated.
Exceptions
Type Condition
ArgumentOutOfRangeException The specified number of milliseconds is outside the range of [-18, +18] hours.

FromNanoseconds(long)

Returns an offset for the given number of nanoseconds, which may be negative.
Declaration
public static Offset FromNanoseconds(long nanoseconds)
Parameters
Type Name Description
long nanoseconds The number of nanoseconds specifying the length of the new offset.
Returns
Type Description
Offset An offset representing the given number of nanoseconds, to the (truncated) second.
Remarks
Offsets are only accurate to second precision; the given number of nanoseconds is simply divided by 1,000,000,000 to give the number of seconds - any remainder is truncated towards zero.
Exceptions
Type Condition
ArgumentOutOfRangeException The specified number of nanoseconds is outside the range of [-18, +18] hours.

FromSeconds(int)

Returns an offset for the given seconds value, which may be negative.
Declaration
public static Offset FromSeconds(int seconds)
Parameters
Type Name Description
int seconds The int seconds value.
Returns
Type Description
Offset An offset representing the given number of seconds.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The specified number of seconds is outside the range of [-18, +18] hours.

FromTicks(long)

Returns an offset for the given number of ticks, which may be negative.
Declaration
public static Offset FromTicks(long ticks)
Parameters
Type Name Description
long ticks The number of ticks specifying the length of the new offset.
Returns
Type Description
Offset An offset representing the given number of ticks, to the (truncated) second.
Remarks
Offsets are only accurate to second precision; the given number of ticks is simply divided by 10,000,000 to give the number of seconds - any remainder is truncated.
Exceptions
Type Condition
ArgumentOutOfRangeException The specified number of ticks is outside the range of [-18, +18] hours.

FromTimeSpan(TimeSpan)

Converts the given TimeSpan to an offset, with fractional seconds truncated.
Declaration
public static Offset FromTimeSpan(TimeSpan timeSpan)
Parameters
Type Name Description
TimeSpan timeSpan The timespan to convert
Returns
Type Description
Offset An offset for the same time as the given time span.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The given time span falls outside the range of +/- 18 hours.

GetHashCode()

Returns a hash code for this instance. See the type documentation for a description of equality semantics.
Declaration
public override int GetHashCode()
Returns
Type Description
int A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Overrides
ValueType.GetHashCode()
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Max(Offset, Offset)

Returns the greater offset of the given two, i.e. the one which will give a later local time when added to an instant.
Declaration
public static Offset Max(Offset x, Offset y)
Parameters
Type Name Description
Offset x The first offset
Offset y The second offset
Returns
Type Description
Offset The greater offset of x and y.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Min(Offset, Offset)

Returns the lower offset of the given two, i.e. the one which will give an earlier local time when added to an instant.
Declaration
public static Offset Min(Offset x, Offset y)
Parameters
Type Name Description
Offset x The first offset
Offset y The second offset
Returns
Type Description
Offset The lower offset of x and y.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Minus(Offset)

Returns the result of subtracting another Offset from this one, for a fluent alternative to operator-().
Declaration
public Offset Minus(Offset other)
Parameters
Type Name Description
Offset other The offset to subtract
Returns
Type Description
Offset The result of subtracting the other offset from this one.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

Negate(Offset)

Returns the negation of the specified offset. This is the method form of the unary minus operator.
Declaration
public static Offset Negate(Offset offset)
Parameters
Type Name Description
Offset offset The offset to negate.
Returns
Type Description
Offset The negation of the specified offset.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Plus(Offset)

Returns the result of adding another Offset to this one, for a fluent alternative to operator+().
Declaration
public Offset Plus(Offset other)
Parameters
Type Name Description
Offset other The offset to add
Returns
Type Description
Offset The result of adding the other offset to this one.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

Subtract(Offset, Offset)

Subtracts one Offset from another. Friendly alternative to operator-().
Declaration
public static Offset Subtract(Offset minuend, Offset subtrahend)
Parameters
Type Name Description
Offset minuend The left hand side of the operator.
Offset subtrahend The right hand side of the operator.
Returns
Type Description
Offset A new Offset representing the difference of the given values.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

ToString()

Returns a String that represents this instance.
Declaration
public override string ToString()
Returns
Type Description
string The value of the current instance in the default format pattern ("g"), using the current thread's culture to obtain a format provider.
Overrides
ValueType.ToString()
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

ToString(string?, IFormatProvider?)

Formats the value of the current instance using the specified pattern.
Declaration
public string ToString(string? patternText, IFormatProvider? formatProvider)
Parameters
Type Name Description
string patternText The String specifying the pattern to use, or null to use the default format pattern ("g").
IFormatProvider formatProvider The IFormatProvider to use when formatting the value, or null to use the current thread's culture to obtain a format provider.
Returns
Type Description
string A String containing the value of the current instance in the specified format.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

ToTimeSpan()

Converts this offset to a .NET standard TimeSpan value.
Declaration
public TimeSpan ToTimeSpan()
Returns
Type Description
TimeSpan An equivalent TimeSpan to this value.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Operators

operator +(Offset, Offset)

Implements the operator + (addition).
Declaration
public static Offset operator +(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
Offset A new Offset representing the sum of the given values.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

operator ==(Offset, Offset)

Implements the operator == (equality). See the type documentation for a description of equality semantics.
Declaration
public static bool operator ==(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
bool true if values are equal to each other, otherwise false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator >(Offset, Offset)

Implements the operator > (greater than). See the type documentation for a description of ordering semantics.
Declaration
public static bool operator >(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
bool true if the left value is greater than the right value, otherwise false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator >=(Offset, Offset)

Implements the operator >= (greater than or equal). See the type documentation for a description of ordering semantics.
Declaration
public static bool operator >=(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
bool true if the left value is greater than or equal to the right value, otherwise false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator !=(Offset, Offset)

Implements the operator != (inequality). See the type documentation for a description of equality semantics.
Declaration
public static bool operator !=(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
bool true if values are not equal to each other, otherwise false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator <(Offset, Offset)

Implements the operator < (less than). See the type documentation for a description of ordering semantics.
Declaration
public static bool operator <(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
bool true if the left value is less than the right value, otherwise false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator <=(Offset, Offset)

Implements the operator <= (less than or equal). See the type documentation for a description of ordering semantics.
Declaration
public static bool operator <=(Offset left, Offset right)
Parameters
Type Name Description
Offset left The left hand side of the operator.
Offset right The right hand side of the operator.
Returns
Type Description
bool true if the left value is less than or equal to the right value, otherwise false.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator -(Offset, Offset)

Implements the operator - (subtraction).
Declaration
public static Offset operator -(Offset minuend, Offset subtrahend)
Parameters
Type Name Description
Offset minuend The left hand side of the operator.
Offset subtrahend The right hand side of the operator.
Returns
Type Description
Offset A new Offset representing the difference of the given values.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Exceptions
Type Condition
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.
ArgumentOutOfRangeException The result of the operation is outside the range of Offset.

operator -(Offset)

Implements the unary operator - (negation).
Declaration
public static Offset operator -(Offset offset)
Parameters
Type Name Description
Offset offset The offset to negate.
Returns
Type Description
Offset A new Offset instance with a negated value.
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

operator +(Offset)

Implements the unary operator + .
Declaration
public static Offset operator +(Offset offset)
Parameters
Type Name Description
Offset offset The operand.
Returns
Type Description
Offset The same Offset instance
Remarks
There is no method form of this operator; the Plus(Offset) method is an instance method for addition, and is more useful than a method form of this would be.

Explicit Interface Implementations

IComparable.CompareTo(object?)

Implementation of CompareTo(Object) to compare two offsets. See the type documentation for a description of ordering semantics.
Declaration
int IComparable.CompareTo(object? obj)
Parameters
Type Name Description
object obj The object to compare this value with.
Returns
Type Description
int The result of comparing this instant with another one; see CompareTo(Offset) for general details. If obj is null, this method returns a value greater than 0.
Remarks
This uses explicit interface implementation to avoid it being called accidentally. The generic implementation should usually be preferred.
Exceptions
Type Condition
ArgumentException obj is non-null but does not refer to an instance of Offset.

IXmlSerializable.ReadXml(XmlReader)

Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type Name Description
XmlReader reader
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

IXmlSerializable.WriteXml(XmlWriter)

Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type Name Description
XmlWriter writer
Remarks

Offsets are always in the range of [-18, +18] hours. (Note that the ends are inclusive, so an offset of 18 hours can be represented, but an offset of 18 hours and one second cannot.) This allows all offsets within TZDB to be represented. The BCL DateTimeOffset type only allows offsets up to 14 hours, which means some historical data within TZDB could not be represented.

Offsets are represented with a granularity of one second. This allows all offsets within TZDB to be represented. It is possible that it could present issues to some other time zone data sources, but only in very rare historical cases (or fictional ones).

Equality and ordering are defined in the natural way by comparing the underlying number of seconds. For example, this means that offsets for America are ordered before offsets in Europe.

The default value of this type is Zero.

Implements

System.IEquatable<T>
System.IComparable<T>
System.IFormattable
System.IComparable
System.Xml.Serialization.IXmlSerializable
In This Article
Back to top Generated by DocFX