Class DateTimeExtensions
Extension methods for System.DateTime.
Since 2.0.x
Availability net6.0, netstandard2.0
Inheritance
Object
DateTimeExtensions
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 DateTimeExtensions
Methods
ToInstant(DateTime)
Since 2.0.x
Availability net6.0, netstandard2.0
Declaration
public static Instant ToInstant(this DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | The DateTime to convert. |
Returns
Type | Description |
---|---|
Instant | An Instant value representing the same instant in time as dateTime . |
Remarks
This is a convenience method which calls FromDateTimeUtc(DateTime).
Exceptions
Type | Condition |
---|---|
ArgumentException | dateTime does not have a kind of Utc . |
ToLocalDateTime(DateTime)
Converts a System.DateTime of any kind to LocalDateTime.
Since 2.0.x
Availability net6.0, netstandard2.0
Declaration
public static LocalDateTime ToLocalDateTime(this DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
DateTime | dateTime | The DateTime to convert. |
Returns
Type | Description |
---|---|
LocalDateTime | A new LocalDateTime with the same values as dateTime . |
Remarks
This is a convenience method which calls FromDateTime(DateTime).