Class DateTimeOffsetExtensions
Extension methods for System.DateTimeOffset.
Since 2.0.x
Availability net6.0, netstandard2.0
Inheritance
Object
DateTimeOffsetExtensions
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: NodaTime.Extensions
Assembly: NodaTime.dll
Syntax
public static class DateTimeOffsetExtensions
Methods
ToInstant(DateTimeOffset)
Converts a System.DateTimeOffset into an Instant.
Since 2.0.x
Availability net6.0, netstandard2.0
Declaration
public static Instant ToInstant(this DateTimeOffset dateTimeOffset)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dateTimeOffset | The DateTimeOffset to convert. |
Returns
Type | Description |
---|---|
Instant | An Instant value representing the same instant in time as dateTimeOffset . |
Remarks
This is a convenience method which calls FromDateTimeOffset(DateTimeOffset).
ToOffsetDateTime(DateTimeOffset)
Converts a System.DateTimeOffset to OffsetDateTime.
Since 2.0.x
Availability net6.0, netstandard2.0
Declaration
public static OffsetDateTime ToOffsetDateTime(this DateTimeOffset dateTimeOffset)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dateTimeOffset | The DateTimeOffset to convert. |
Returns
Type | Description |
---|---|
OffsetDateTime | A new OffsetDateTime with the same values as dateTimeOffset . |
Remarks
This is a convenience method which calls FromDateTimeOffset(DateTimeOffset).
ToZonedDateTime(DateTimeOffset)
Converts a System.DateTimeOffset to ZonedDateTime.
Since 2.0.x
Availability net6.0, netstandard2.0
Declaration
public static ZonedDateTime ToZonedDateTime(this DateTimeOffset dateTimeOffset)
Parameters
Type | Name | Description |
---|---|---|
DateTimeOffset | dateTimeOffset | The DateTimeOffset to convert. |
Returns
Type | Description |
---|---|
ZonedDateTime | A new ZonedDateTime with the same values as dateTimeOffset ,
using a fixed-offset time zone. |
Remarks
This is a convenience method which calls FromDateTimeOffset(DateTimeOffset).