Skip to content

Commit

Permalink
dateonly extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasteles committed Apr 10, 2023
1 parent edf32ae commit 1667a36
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/DateTimeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ public static class DateTimeExtensions
public static TimeOnly ToTimeOnly(this DateTime dateTime) =>
TimeOnly.FromDateTime(dateTime);

/// <summary>
/// Returns a DateTime instance with the specified input kind that is set to the date of this DateOnly instance and the time at UTC 00:00AM.
/// </summary>
public static DateTime ToDateTime(this DateOnly dateOnly) =>
dateOnly.ToDateTime(default, DateTimeKind.Utc);

/// <summary>
/// Returns a DateTime instance with the specified input kind that is set to the date of this DateOnly instance and the time at 00:00AM.
/// </summary>
public static DateTime
ToDateTime(this DateOnly dateOnly,
TimeOnly time = default,
DateTimeKind kind = DateTimeKind.Utc) =>
dateOnly.ToDateTime(time, kind);
public static DateTime ToDateTime(this DateOnly dateOnly, DateTimeKind kind) =>
dateOnly.ToDateTime(default, kind);
}

0 comments on commit 1667a36

Please sign in to comment.