Skip to content

Commit

Permalink
Utc method should return the Utc DateTimeKind (#126)
Browse files Browse the repository at this point in the history
+ Updated unit tests to properly compare expected and output
  • Loading branch information
aaron-hardin authored Feb 21, 2024
1 parent c874758 commit 77fee5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ DateTime expected

var output = tzMock.Object.EnsureLocalTime(input);
Assert.AreEqual(expected.ToString(), output.ToString());
Assert.AreEqual
(
expected.Kind,
input.Kind == DateTimeKind.Unspecified
? DateTimeKind.Unspecified
: DateTimeKind.Local
);

Assert.AreEqual(expected.Kind, output.Kind);
}

public static IEnumerable<object[]> GetEnsureLocalTimeData()
Expand Down Expand Up @@ -69,14 +62,7 @@ DateTime expected

var output = tzMock.Object.EnsureUTCTime(input);
Assert.AreEqual(expected.ToString(), output.ToString());
Assert.AreEqual
(
expected.Kind,
input.Kind == DateTimeKind.Unspecified
? DateTimeKind.Unspecified
: DateTimeKind.Utc
);

Assert.AreEqual(expected.Kind, output.Kind);
}

public static IEnumerable<object[]> GetEnsureUtcTimeData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static DateTime EnsureUTCTime(this TimeZoneInformation timeZoneInfo, Date
{
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(timeZoneInfo.StandardName);
var output = input.Subtract(tzi.GetUtcOffset(input));
return DateTime.SpecifyKind(output, DateTimeKind.Local);
return DateTime.SpecifyKind(output, DateTimeKind.Utc);
}
catch (Exception ex)
{
Expand Down

0 comments on commit 77fee5b

Please sign in to comment.