Skip to content

Commit 40afd9c

Browse files
committed
Remove time part on DateRange ctor
1 parent 1d38da9 commit 40afd9c

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

src/Unosquare.DateTimeExt/DateRange.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public DateRange(IReadOnlyDateRange range)
2323
}
2424

2525
public DateRange(DateTime startDate, DateTime? endDate = null)
26-
: base(startDate, endDate ?? startDate)
26+
: base(startDate.Date, endDate?.Date ?? startDate.Date)
2727
{
2828
if (EndDate < StartDate)
2929
throw new ArgumentOutOfRangeException(nameof(endDate), "End Date should be after Start Date");
3030
}
3131

32-
public DateTime MidnightEndDate => EndDate.Date.AddDays(1).AddSeconds(-1);
32+
public DateTime MidnightEndDate => EndDate.AddDays(1).AddSeconds(-1);
3333

3434
public DateTime FirstBusinessDay => StartDate.GetFirstBusinessDayOfMonth();
3535

@@ -85,7 +85,7 @@ public int CompareTo(DateRange? other)
8585

8686
public static bool TryParse(string? value, out DateRange result)
8787
{
88-
result = default!;
88+
result = null!;
8989

9090
if (string.IsNullOrWhiteSpace(value))
9191
return false;

src/Unosquare.DateTimeExt/YearMonth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public YearMonth(IYearWeek yearWeek)
4646

4747
public static bool TryParse(string? value, out YearMonth range)
4848
{
49-
range = default!;
49+
range = null!;
5050

5151
if (value == null)
5252
return false;

src/Unosquare.DateTimeExt/YearQuarter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public int CompareTo(YearQuarter? other)
7474

7575
public static bool TryParse(string? value, out YearQuarter result)
7676
{
77-
result = default!;
77+
result = null!;
7878

7979
if (string.IsNullOrWhiteSpace(value))
8080
return false;

src/Unosquare.DateTimeExt/YearWeek.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public int CompareTo(YearWeek? other)
5656

5757
public static bool TryParse(string? value, out YearWeek result)
5858
{
59-
result = default!;
59+
result = null!;
6060

6161
if (string.IsNullOrWhiteSpace(value))
6262
return false;

src/Unosquare.DateTimeExt/YearWeekIso.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public int CompareTo(YearWeekIso? other)
4848

4949
public static bool TryParse(string? value, out YearWeekIso result)
5050
{
51-
result = default!;
51+
result = null!;
5252

5353
if (string.IsNullOrWhiteSpace(value))
5454
return false;

test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeek-Tests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public void WithWeek_Deconstruct()
99
yearMonth.Deconstruct(out DateTime startDate, out var endDate);
1010

1111
Assert.Equal(new(2022, 1, 2), startDate);
12-
Assert.Equal(new DateTime(2022, 1, 8).ToMidnight(), endDate);
12+
Assert.Equal(new(2022, 1, 8), endDate);
1313
}
1414

1515
[Fact]
@@ -27,7 +27,7 @@ public void WithWeek_DateRange()
2727
var yearMonth = new YearWeek(1, 2022);
2828

2929
Assert.Equal(new(2022, 1, 2), yearMonth.StartDate);
30-
Assert.Equal(new DateTime(2022, 1, 8).ToMidnight(), yearMonth.EndDate);
30+
Assert.Equal(new(2022, 1, 8), yearMonth.EndDate);
3131
}
3232

3333
[Fact]

test/Unosquare.DateTimeExt.Test/Unosquare.DateTimeExt.Test/YearWeekIsoTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public void WithWeek_Deconstruct()
99
yearMonth.Deconstruct(out DateTime startDate, out var endDate);
1010

1111
Assert.Equal(new(2022, 1, 3), startDate);
12-
Assert.Equal(new DateTime(2022, 1, 9).ToMidnight(), endDate);
12+
Assert.Equal(new(2022, 1, 9), endDate);
1313
}
1414

1515
[Fact]
@@ -27,7 +27,7 @@ public void WithWeek_DateRange()
2727
var yearMonth = new YearWeekIso(1, 2022);
2828

2929
Assert.Equal(new(2022, 1, 3), yearMonth.StartDate);
30-
Assert.Equal(new DateTime(2022, 1, 9).ToMidnight(), yearMonth.EndDate);
30+
Assert.Equal(new(2022, 1, 9), yearMonth.EndDate);
3131
}
3232

3333
[Fact]

0 commit comments

Comments
 (0)