Class DateTimeOffsetExtensions
Extension methods for DateTimeOffset.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Inherited Members
Namespace: NodaTime.Extensions
Assembly: NodaTime.dll
Syntax
public static class DateTimeOffsetExtensions
Methods
ToInstant(DateTimeOffset)
Converts a DateTimeOffset into an Instant.
Since 2.0.x
Availability net6.0, net8.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 DateTimeOffset to OffsetDateTime.
Since 2.0.x
Availability net6.0, net8.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 DateTimeOffset to ZonedDateTime.
Since 2.0.x
Availability net6.0, net8.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).