From 4071650a770e874143aefb23dfcb8974565e91d0 Mon Sep 17 00:00:00 2001 From: axunonb Date: Wed, 2 Oct 2024 09:04:46 +0200 Subject: [PATCH] Make TimeZoneConverter.ToUtc(DateTime, string) static --- Axuno.Tools.Tests/DateAndTime/TimeZoneConverterTests.cs | 4 ++-- Axuno.Tools/DateAndTime/TimeZoneConverter.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Axuno.Tools.Tests/DateAndTime/TimeZoneConverterTests.cs b/Axuno.Tools.Tests/DateAndTime/TimeZoneConverterTests.cs index e388945..93192cb 100644 --- a/Axuno.Tools.Tests/DateAndTime/TimeZoneConverterTests.cs +++ b/Axuno.Tools.Tests/DateAndTime/TimeZoneConverterTests.cs @@ -134,7 +134,7 @@ public void ConvertTimeWithZoneIdToUtc_ShouldReturnCorrectDateTime() var expectedDateTime = new DateTime(2022, 1, 1, 7, 0, 0, DateTimeKind.Utc); // Act - var convertedDateTime = GetTimeZoneConverter("en-US").ToUtc(localDateTime, "Europe/Berlin"); + var convertedDateTime = Axuno.Tools.DateAndTime.TimeZoneConverter.ToUtc(localDateTime, "Europe/Berlin"); // Assert Assert.That(convertedDateTime, Is.EqualTo(expectedDateTime)); @@ -186,7 +186,7 @@ public void ConvertTimeZoneToUtc_ShouldReturnNull_WhenDateTimeOfAnyKindIsNull() DateTime? dateTimeOfAnyKind = null; // Act - var convertedDateTime = GetTimeZoneConverter("en-US").ToUtc(dateTimeOfAnyKind, "Europe/Berlin"); + var convertedDateTime = Axuno.Tools.DateAndTime.TimeZoneConverter.ToUtc(dateTimeOfAnyKind, "Europe/Berlin"); // Assert Assert.That(convertedDateTime, Is.Null); diff --git a/Axuno.Tools/DateAndTime/TimeZoneConverter.cs b/Axuno.Tools/DateAndTime/TimeZoneConverter.cs index 251df0f..d326ac8 100644 --- a/Axuno.Tools/DateAndTime/TimeZoneConverter.cs +++ b/Axuno.Tools/DateAndTime/TimeZoneConverter.cs @@ -71,7 +71,7 @@ public DateTime ToUtc(DateTime zoneDateTime) return ToUtc(zoneDateTime, _ianaTimeZoneId); } - public DateTime? ToUtc(DateTime? zoneDateTime, string timeZoneId) + public static DateTime? ToUtc(DateTime? zoneDateTime, string timeZoneId) { if (!zoneDateTime.HasValue) return null; @@ -94,7 +94,7 @@ public DateTime ToUtc(DateTime zoneDateTime) /// The ID of the IANA timezone database, https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. /// Returns the converted with . /// If is unknown. - public DateTime ToUtc(DateTime zoneDateTime, string timeZoneId) + public static DateTime ToUtc(DateTime zoneDateTime, string timeZoneId) { return (DateTime) ToUtc((DateTime?) zoneDateTime, timeZoneId)!; }