Noda Time
Show / Hide Table of Contents

Struct OffsetTime

A combination of a LocalTime and an Offset, to represent a time-of-day at a specific offset from UTC but without any date information.
Since 2.3.x
Availability net45, netstandard1.3
Implements
IEquatable<OffsetTime>
IXmlSerializable
IFormattable
ISerializable
Inherited Members
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetType()
Namespace: NodaTime
Assembly: NodaTime.dll
Syntax
[Serializable]
public struct OffsetTime : IEquatable<OffsetTime>, IXmlSerializable, IFormattable, ISerializable

Constructors

OffsetTime(LocalTime, Offset)

Constructs an instance of the specified time and offset.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTime(LocalTime time, Offset offset)
Parameters
Type Name Description
LocalTime time The time part of the value.
Offset offset The offset part of the value.

Properties

ClockHourOfHalfDay

Gets the hour of the half-day of this offset time, in the range 1 to 12 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int ClockHourOfHalfDay { get; }
Property Value
Type Description
Int32 The hour of the half-day of this offset time, in the range 1 to 12 inclusive.

Hour

Gets the hour of day of this offset time, in the range 0 to 23 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int Hour { get; }
Property Value
Type Description
Int32 The hour of day of this offset time, in the range 0 to 23 inclusive.

Millisecond

Gets the millisecond of this offset time within the second, in the range 0 to 999 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int Millisecond { get; }
Property Value
Type Description
Int32 The millisecond of this offset time within the second, in the range 0 to 999 inclusive.

Minute

Gets the minute of this offset time, in the range 0 to 59 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int Minute { get; }
Property Value
Type Description
Int32 The minute of this offset time, in the range 0 to 59 inclusive.

NanosecondOfDay

Gets the nanosecond of this offset time within the day, in the range 0 to 86,399,999,999,999 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public long NanosecondOfDay { get; }
Property Value
Type Description
Int64 The nanosecond of this offset time within the day, in the range 0 to 86,399,999,999,999 inclusive.

NanosecondOfSecond

Gets the nanosecond of this offset time within the second, in the range 0 to 999,999,999 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int NanosecondOfSecond { get; }
Property Value
Type Description
Int32 The nanosecond of this offset time within the second, in the range 0 to 999,999,999 inclusive.

Offset

Gets the offset from UTC of this value. The offset from UTC of this value.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public Offset Offset { get; }
Property Value
Type Description
Offset

Second

Gets the second of this offset time within the minute, in the range 0 to 59 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int Second { get; }
Property Value
Type Description
Int32 The second of this offset time within the minute, in the range 0 to 59 inclusive.

TickOfDay

Gets the tick of this offset time within the day, in the range 0 to 863,999,999,999 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public long TickOfDay { get; }
Property Value
Type Description
Int64 The tick of this offset time within the day, in the range 0 to 863,999,999,999 inclusive.
Remarks
If the value does not fall on a tick boundary, it will be truncated towards zero.

TickOfSecond

Gets the tick of this offset time within the second, in the range 0 to 9,999,999 inclusive.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public int TickOfSecond { get; }
Property Value
Type Description
Int32 The tick of this offset time within the second, in the range 0 to 9,999,999 inclusive.

TimeOfDay

Gets the time-of-day represented by this value.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public LocalTime TimeOfDay { get; }
Property Value
Type Description
LocalTime The time-of-day represented by this value.

Methods

Deconstruct(out LocalTime, out Offset)

Deconstruct this value into its components.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public void Deconstruct(out LocalTime localTime, out Offset offset)
Parameters
Type Name Description
LocalTime localTime The LocalTime component.
Offset offset The Offset component.

Equals(OffsetTime)

Compares two OffsetTime values for equality. This requires that the date values be the same and the offsets.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public bool Equals(OffsetTime other)
Parameters
Type Name Description
OffsetTime other The value to compare this offset time with.
Returns
Type Description
Boolean True if the given value is another offset time equal to this one; false otherwise.

Equals(Object)

Compares two OffsetTime values for equality. This requires that the time-of-day values be the same and the offsets.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
Object obj The object to compare this offset time with.
Returns
Type Description
Boolean True if the given value is another offset time equal to this one; false otherwise.
Overrides
System.ValueType.Equals(System.Object)

GetHashCode()

Returns a hash code for this offset time.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public override int GetHashCode()
Returns
Type Description
Int32 A hash code for this offset time.
Overrides
System.ValueType.GetHashCode()

On(LocalDate)

Combines this OffsetTime with the given LocalDate into an OffsetDateTime.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetDateTime On(LocalDate date)
Parameters
Type Name Description
LocalDate date The date to combine with this time-of-day.
Returns
Type Description
OffsetDateTime The OffsetDateTime representation of this time-of-day on the given date.

ToString()

Returns a System.String that represents this instance.
Since 2.3.x
Availability net45, netstandard1.3
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
System.ValueType.ToString()

ToString(String, IFormatProvider)

Formats the value of the current instance using the specified pattern.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public string ToString(string patternText, IFormatProvider formatProvider)
Parameters
Type Name Description
String patternText The System.String specifying the pattern to use, or null to use the default format pattern ("G").
IFormatProvider formatProvider The System.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 System.String containing the value of the current instance in the specified format.

With(Func<LocalTime, LocalTime>)

Returns this offset time-of-day, with the given date adjuster applied to it, maintaining the existing offset.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTime With(Func<LocalTime, LocalTime> adjuster)
Parameters
Type Name Description
Func<LocalTime, LocalTime> adjuster The adjuster to apply.
Returns
Type Description
OffsetTime The adjusted offset date.
Remarks
If the adjuster attempts to construct an invalid time-of-day, any exception thrown by that construction attempt will be propagated through this method.
Exceptions
Type Condition
ArgumentNullException adjuster is null.

WithOffset(Offset)

Creates a new OffsetTime for the same time-of-day, but with the specified UTC offset.
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public OffsetTime WithOffset(Offset offset)
Parameters
Type Name Description
Offset offset The new UTC offset.
Returns
Type Description
OffsetTime A new OffsetTime for the same date, but with the specified UTC offset.

Operators

Equality(OffsetTime, OffsetTime)

Implements the operator == (equality).
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static bool operator ==(OffsetTime left, OffsetTime right)
Parameters
Type Name Description
OffsetTime left The left hand side of the operator.
OffsetTime right The right hand side of the operator.
Returns
Type Description
Boolean true if values are equal to each other, otherwise false.

Inequality(OffsetTime, OffsetTime)

Implements the operator != (inequality).
Since 2.3.x
Availability net45, netstandard1.3
Declaration
public static bool operator !=(OffsetTime left, OffsetTime right)
Parameters
Type Name Description
OffsetTime left The left hand side of the operator.
OffsetTime right The right hand side of the operator.
Returns
Type Description
Boolean true if values are not equal to each other, otherwise false.

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Implementation of System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext).
Since 2.3.x
Availability net45
Declaration
[SecurityCritical]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
SerializationInfo info The System.Runtime.Serialization.SerializationInfo to populate with data.
StreamingContext context The destination for this serialization.
Exceptions
Type Condition
ArgumentNullException info is null.

IXmlSerializable.GetSchema()

Since 2.3.x
Availability net45, netstandard1.3
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type Description
XmlSchema

IXmlSerializable.ReadXml(XmlReader)

Since 2.3.x
Availability net45, netstandard1.3
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
Type Name Description
XmlReader reader
Exceptions
Type Condition
ArgumentNullException reader is null.

IXmlSerializable.WriteXml(XmlWriter)

Since 2.3.x
Availability net45, netstandard1.3
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Type Name Description
XmlWriter writer
Exceptions
Type Condition
ArgumentNullException writer is null.

Implements

System.IEquatable<T>
System.Xml.Serialization.IXmlSerializable
System.IFormattable
System.Runtime.Serialization.ISerializable
In this article
Back to top Generated by DocFX