Noda Time
Show / Hide Table of Contents

Class DateTimeExtensions

Extension methods for System.DateTime.
Since 2.0.x
Availability net45, netstandard1.3, netstandard2.0
Inheritance
Object
DateTimeExtensions
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: NodaTime.Extensions
Assembly: NodaTime.dll
Syntax
public static class DateTimeExtensions

Methods

ToInstant(DateTime)

Converts a System.DateTime with a kind of System.DateTimeKind.Utc into an Instant.
Since 2.0.x
Availability net45, netstandard1.3, 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 net45, netstandard1.3, 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).
In this article
Back to top Generated by DocFX