Skip to content

Commit

Permalink
Ajust YearWeek EndDate to midnight and adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarfgq authored and geoperez committed Jan 8, 2024
1 parent 185979b commit c282ea6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Unosquare.DateTimeExt/YearWeek.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Unosquare.DateTimeExt;
public sealed class YearWeek : YearWeekBase, IComparable<YearWeek>
{
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();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Unosquare.DateTimeExt/YearWeekIso.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Unosquare.DateTimeExt;
public sealed class YearWeekIso : YearWeekBase, IComparable<YearWeekIso>
{
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())
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down

0 comments on commit c282ea6

Please sign in to comment.