Skip to content

Commit

Permalink
Make TimeZoneConverter.ToUtc(DateTime, string) static
Browse files Browse the repository at this point in the history
  • Loading branch information
axunonb committed Oct 2, 2024
1 parent a4f122f commit 4071650
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Axuno.Tools.Tests/DateAndTime/TimeZoneConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Axuno.Tools/DateAndTime/TimeZoneConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -94,7 +94,7 @@ public DateTime ToUtc(DateTime zoneDateTime)
/// <param name="timeZoneId">The ID of the IANA timezone database, https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.</param>
/// <returns>Returns the converted <see cref="DateTime"/> with <see cref="DateTimeKind.Utc"/>.</returns>
/// <exception cref="TimeZoneNotFoundException">If <paramref name="timeZoneId"/> is unknown.</exception>
public DateTime ToUtc(DateTime zoneDateTime, string timeZoneId)
public static DateTime ToUtc(DateTime zoneDateTime, string timeZoneId)
{
return (DateTime) ToUtc((DateTime?) zoneDateTime, timeZoneId)!;
}
Expand Down

0 comments on commit 4071650

Please sign in to comment.