Noda Time
Show / Hide Table of Contents

Struct OffsetDate

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

Constructors

OffsetDate(LocalDate, Offset)

Constructs an instance of the specified date and offset.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public OffsetDate(LocalDate date, Offset offset)
Parameters
Type Name Description
LocalDate date The date part of the value.
Offset offset The offset part of the value.

Properties

Calendar

Gets the calendar system associated with this offset date.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public CalendarSystem Calendar { get; }
Property Value
Type Description
CalendarSystem The calendar system associated with this offset date. (The value returned is never null.)

Date

Gets the local date represented by this value.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public LocalDate Date { get; }
Property Value
Type Description
LocalDate The local date represented by this value.

Day

Gets the day of this offset date within the month.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public int Day { get; }
Property Value
Type Description
Int32 The day of this offset date within the month.

DayOfWeek

Gets the week day of this offset date expressed as an IsoDayOfWeek value.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public IsoDayOfWeek DayOfWeek { get; }
Property Value
Type Description
IsoDayOfWeek The week day of this offset date expressed as an IsoDayOfWeek.

DayOfYear

Gets the day of this offset date within the year.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public int DayOfYear { get; }
Property Value
Type Description
Int32 The day of this offset date within the year.

Era

Gets the era of this offset date.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public Era Era { get; }
Property Value
Type Description
Era The era of this offset date. (The value returned is never null.)

Month

Gets the month of this offset date within the year.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public int Month { get; }
Property Value
Type Description
Int32 The month of this offset date within the year.

Offset

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

Year

Gets the year of this offset date.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public int Year { get; }
Property Value
Type Description
Int32 The year of this offset date.
Remarks
This returns the "absolute year", so, for the ISO calendar, a value of 0 means 1 BC, for example.

YearOfEra

Gets the year of this offset date within the era.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public int YearOfEra { get; }
Property Value
Type Description
Int32 The year of this offset date within the era.

Methods

At(LocalTime)

Combines this OffsetDate with the given LocalTime into an OffsetDateTime.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public OffsetDateTime At(LocalTime time)
Parameters
Type Name Description
LocalTime time The time to combine with this date.
Returns
Type Description
OffsetDateTime The OffsetDateTime representation of the given time on this date.

Deconstruct(out LocalDate, out Offset)

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

Equals(OffsetDate)

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

Equals(Object)

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

GetHashCode()

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

ToString()

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

Returns this offset date, with the given date adjuster applied to it, maintaining the existing offset.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public OffsetDate With(Func<LocalDate, LocalDate> adjuster)
Parameters
Type Name Description
Func<LocalDate, LocalDate> adjuster The adjuster to apply.
Returns
Type Description
OffsetDate The adjusted offset date.
Remarks
If the adjuster attempts to construct an invalid date (such as by trying to set a day-of-month of 30 in February), any exception thrown by that construction attempt will be propagated through this method.
Exceptions
Type Condition
ArgumentNullException adjuster is null.

WithCalendar(CalendarSystem)

Creates a new OffsetDate representing the same physical date and offset, but in a different calendar. The returned value is likely to have different date field values to this one. For example, January 1st 1970 in the Gregorian calendar was December 19th 1969 in the Julian calendar.
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public OffsetDate WithCalendar(CalendarSystem calendar)
Parameters
Type Name Description
CalendarSystem calendar The calendar system to convert this offset date to.
Returns
Type Description
OffsetDate The converted OffsetDate.
Exceptions
Type Condition
ArgumentNullException calendar is null.

WithOffset(Offset)

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

Operators

Equality(OffsetDate, OffsetDate)

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

Inequality(OffsetDate, OffsetDate)

Implements the operator != (inequality).
Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
Declaration
public static bool operator !=(OffsetDate left, OffsetDate right)
Parameters
Type Name Description
OffsetDate left The left hand side of the operator.
OffsetDate 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, netstandard2.0
Declaration
XmlSchema IXmlSerializable.GetSchema()
Returns
Type Description
XmlSchema

IXmlSerializable.ReadXml(XmlReader)

Since 2.3.x
Availability net45, netstandard1.3, netstandard2.0
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, netstandard2.0
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