From 7ea0e4469b93053d0f0c3fd63c426d3a872c32d5 Mon Sep 17 00:00:00 2001 From: Oscar Gonzalez Date: Mon, 8 Jan 2024 16:32:38 -0400 Subject: [PATCH] Ajust YearWeek EndDate to midnight and adjust tests --- src/Unosquare.DateTimeExt/YearWeek.cs | 2 +- src/Unosquare.DateTimeExt/YearWeekIso.cs | 2 +- .../Unosquare.DateTimeExt.Test/Date-Extensions-Tests.cs | 2 +- .../Unosquare.DateTimeExt.Test/YearWeek-Tests.cs | 4 ++-- .../Unosquare.DateTimeExt.Test/YearWeekIsoTests.cs | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Unosquare.DateTimeExt/YearWeek.cs b/src/Unosquare.DateTimeExt/YearWeek.cs index 110ecb0..a2a75e1 100644 --- a/src/Unosquare.DateTimeExt/YearWeek.cs +++ b/src/Unosquare.DateTimeExt/YearWeek.cs @@ -5,7 +5,7 @@ namespace Unosquare.DateTimeExt; public sealed class YearWeek : YearWeekBase, IComparable { public YearWeek(int? week = null, int? year = null) - : base(GetStartDate(week, year), GetStartDate(week, year).AddDays(6)) + : base(GetStartDate(week, year), GetStartDate(week, year).AddDays(6).ToMidnight()) { Week = StartDate.GetWeekOfYear(); } diff --git a/src/Unosquare.DateTimeExt/YearWeekIso.cs b/src/Unosquare.DateTimeExt/YearWeekIso.cs index 08741cc..cca3e71 100644 --- a/src/Unosquare.DateTimeExt/YearWeekIso.cs +++ b/src/Unosquare.DateTimeExt/YearWeekIso.cs @@ -5,7 +5,7 @@ namespace Unosquare.DateTimeExt; public sealed class YearWeekIso : YearWeekBase, IComparable { public YearWeekIso(int week, int year) - : base(ISOWeek.ToDateTime(year, week, DayOfWeek.Monday), ISOWeek.ToDateTime(year, week, DayOfWeek.Sunday)) + : base(ISOWeek.ToDateTime(year, week, DayOfWeek.Monday), ISOWeek.ToDateTime(year, week, DayOfWeek.Sunday).ToMidnight()) { } diff --git a/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/Date-Extensions-Tests.cs b/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/Date-Extensions-Tests.cs index b3b4f7e..faf8de0 100644 --- a/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/Date-Extensions-Tests.cs +++ b/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/Date-Extensions-Tests.cs @@ -45,7 +45,7 @@ public void WithNullableDate_ToFormattedString() public void WithDate_ToUTC() { Assert.Equal(new(2022, 6, 1, 5, 0, 0), new DateTime(2022, 6, 1, 0, 0, 0).ToUtc("Central Standard Time (Mexico)")); - Assert.Equal(new(2022, 6, 1, 5, 0, 0), new DateTime(2022, 6, 1, 0, 0, 0).ToUtc("Invalid Timezone Id")); + Assert.Equal(new(2022, 6, 1, 4, 0, 0), new DateTime(2022, 6, 1, 0, 0, 0).ToUtc("Invalid Timezone Id")); } [Fact] diff --git a/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeek-Tests.cs b/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeek-Tests.cs index f537f32..787e85b 100644 --- a/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeek-Tests.cs +++ b/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeek-Tests.cs @@ -9,7 +9,7 @@ public void WithWeek_Deconstruct() yearMonth.Deconstruct(out DateTime startDate, out var endDate); Assert.Equal(new(2022, 1, 2), startDate); - Assert.Equal(new(2022, 1, 8), endDate); + Assert.Equal(new DateTime(2022, 1, 8).ToMidnight(), endDate); } [Fact] @@ -27,7 +27,7 @@ public void WithWeek_DateRange() var yearMonth = new YearWeek(1, 2022); Assert.Equal(new(2022, 1, 2), yearMonth.StartDate); - Assert.Equal(new(2022, 1, 8), yearMonth.EndDate); + Assert.Equal(new DateTime(2022, 1, 8).ToMidnight(), yearMonth.EndDate); } [Fact] diff --git a/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeekIsoTests.cs b/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeekIsoTests.cs index cdcc718..30ffea4 100644 --- a/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeekIsoTests.cs +++ b/test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeekIsoTests.cs @@ -9,7 +9,7 @@ public void WithWeek_Deconstruct() yearMonth.Deconstruct(out DateTime startDate, out var endDate); Assert.Equal(new(2022, 1, 3), startDate); - Assert.Equal(new(2022, 1, 9), endDate); + Assert.Equal(new DateTime(2022, 1, 9).ToMidnight(), endDate); } [Fact] @@ -27,7 +27,7 @@ public void WithWeek_DateRange() var yearMonth = new YearWeekIso(1, 2022); Assert.Equal(new(2022, 1, 3), yearMonth.StartDate); - Assert.Equal(new(2022, 1, 9), yearMonth.EndDate); + Assert.Equal(new DateTime(2022, 1, 9).ToMidnight(), yearMonth.EndDate); } [Fact]