From d14770c184a0fa4eb60a72298b93d8839386d242 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 17 Dec 2019 12:49:32 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Rename=20SetTime=20to=20WithTime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- X10D/src/DateTimeExtensions.cs | 78 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/X10D/src/DateTimeExtensions.cs b/X10D/src/DateTimeExtensions.cs index fb4874b..0cf8d16 100644 --- a/X10D/src/DateTimeExtensions.cs +++ b/X10D/src/DateTimeExtensions.cs @@ -110,43 +110,6 @@ return new DateTime(current.Year, current.Month, current.Day, 12, 0, 0); } - /// - /// Sets the time of the current date with minute precision. - /// - /// The current date. - /// The hour. - /// The minute. - public static DateTime SetTime(this DateTime current, int hour, int minute) - { - return current.SetTime(hour, minute, 0, 0); - } - - /// - /// Sets the time of the current date with second precision. - /// - /// The current date - /// The hour. - /// The minute. - /// The second. - /// - public static DateTime SetTime(this DateTime current, int hour, int minute, int second) - { - return current.SetTime(hour, minute, second, 0); - } - - /// - /// Sets the time of the current date with millisecond precision. - /// - /// The current date. - /// The hour. - /// The minute. - /// The second. - /// The millisecond. - public static DateTime SetTime(this DateTime current, int hour, int minute, int second, int millisecond) - { - return new DateTime(current.Year, current.Month, current.Day, hour, minute, second, millisecond); - } - /// /// Converts the to a Unix timestamp. /// @@ -156,8 +119,8 @@ /// Returns a Unix timestamp representing the provided . public static long ToUnixTimeStamp(this DateTime time, bool useMillis = false) { - DateTimeOffset offset = time.ToUniversalTime(); - return useMillis ? offset.ToUnixTimeSeconds() : offset.ToUnixTimeMilliseconds(); + DateTimeOffset offset = time; + return useMillis ? offset.ToUnixTimeMilliseconds() : offset.ToUnixTimeSeconds(); } /// @@ -170,5 +133,42 @@ { return new DateTime(year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond); } + + /// + /// Sets the time of the current date with minute precision. + /// + /// The current date. + /// The hour. + /// The minute. + public static DateTime WithTime(this DateTime current, int hour, int minute) + { + return current.WithTime(hour, minute, 0); + } + + /// + /// Sets the time of the current date with second precision. + /// + /// The current date + /// The hour. + /// The minute. + /// The second. + /// + public static DateTime WithTime(this DateTime current, int hour, int minute, int second) + { + return current.WithTime(hour, minute, second, 0); + } + + /// + /// Sets the time of the current date with millisecond precision. + /// + /// The current date. + /// The hour. + /// The minute. + /// The second. + /// The millisecond. + public static DateTime WithTime(this DateTime current, int hour, int minute, int second, int millisecond) + { + return new DateTime(current.Year, current.Month, current.Day, hour, minute, second, millisecond); + } } }