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.
Assembly: NodaTime.dll
Syntax
[TypeConverter(typeof(OffsetTimeTypeConverter))]
public readonly struct OffsetTime : IEquatable<OffsetTime>, IXmlSerializable, IFormattable
Constructors
OffsetTime(LocalTime, Offset)
Constructs an instance of the specified time and offset.
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.
Declaration
public int ClockHourOfHalfDay { get; }
Property Value
Type |
Description |
int |
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.
Declaration
Property Value
Type |
Description |
int |
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.
Declaration
public int Millisecond { get; }
Property Value
Type |
Description |
int |
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.
Declaration
public int Minute { get; }
Property Value
Type |
Description |
int |
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.
Declaration
public long NanosecondOfDay { get; }
Property Value
Type |
Description |
long |
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.
Declaration
public int NanosecondOfSecond { get; }
Property Value
Type |
Description |
int |
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.
Declaration
public Offset Offset { get; }
Property Value
Second
Gets the second of this offset time within the minute, in the range 0 to 59 inclusive.
Declaration
public int Second { get; }
Property Value
Type |
Description |
int |
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.
Declaration
public long TickOfDay { get; }
Property Value
Type |
Description |
long |
The tick of this offset time within the day, in the range 0 to 863,999,999,999 inclusive. |
TickOfSecond
Gets the tick of this offset time within the second, in the range 0 to 9,999,999 inclusive.
Declaration
public int TickOfSecond { get; }
Property Value
Type |
Description |
int |
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.
Declaration
public LocalTime TimeOfDay { get; }
Property Value
Type |
Description |
LocalTime |
The time-of-day represented by this value. |
Methods
AddSchema(XmlSchemaSet)
Adds the XML schema type describing the structure of the
OffsetTime XML serialization to the given
xmlSchemaSet
.
Declaration
public static XmlQualifiedName AddSchema(XmlSchemaSet xmlSchemaSet)
Parameters
Returns
Type |
Description |
XmlQualifiedName |
The qualified name of the schema type that was added to the xmlSchemaSet . |
Deconstruct(out LocalTime, out Offset)
Deconstruct this value into its components.
Declaration
public void Deconstruct(out LocalTime localTime, out Offset offset)
Parameters
Equals(OffsetTime)
Compares two
OffsetTime values for equality.
See the type documentation for a description of equality semantics.
Declaration
public bool Equals(OffsetTime other)
Parameters
Type |
Name |
Description |
OffsetTime |
other |
The value to compare this offset time with. |
Returns
Type |
Description |
bool |
True if the given value is another offset time equal to this one; false otherwise. |
Equals(object?)
Compares two
OffsetTime values for equality.
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 this offset time with. |
Returns
Type |
Description |
bool |
True if the given value is another offset time equal to this one; false otherwise. |
Overrides
GetHashCode()
Returns a hash code for this offset time.
See the type documentation for a description of equality semantics.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
int |
A hash code for this offset time. |
Overrides
On(LocalDate)
Declaration
public OffsetDateTime On(LocalDate date)
Parameters
Type |
Name |
Description |
LocalDate |
date |
The date to combine with this time-of-day. |
Returns
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
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.
|
With(Func<LocalTime, LocalTime>)
Returns this offset time-of-day, with the given date adjuster applied to it, maintaining the existing offset.
Declaration
public OffsetTime With(Func<LocalTime, LocalTime> adjuster)
Parameters
Returns
Type |
Description |
OffsetTime |
The adjusted offset date. |
WithOffset(Offset)
Creates a new
OffsetTime for the same time-of-day, but with the specified UTC offset.
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
operator ==(OffsetTime, OffsetTime)
Implements the operator == (equality).
See the type documentation for a description of equality semantics.
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 |
bool |
true if values are equal to each other, otherwise false . |
operator !=(OffsetTime, OffsetTime)
Implements the operator != (inequality).
See the type documentation for a description of equality semantics.
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 |
bool |
true if values are not equal to each other, otherwise false . |
Explicit Interface Implementations
IXmlSerializable.ReadXml(XmlReader)
Declaration
void IXmlSerializable.ReadXml(XmlReader reader)
Parameters
IXmlSerializable.WriteXml(XmlWriter)
Declaration
void IXmlSerializable.WriteXml(XmlWriter writer)
Parameters
Implements