Skip to content

Commit

Permalink
Updated ComputeRealRange to detect when start and end are in the same…
Browse files Browse the repository at this point in the history
… window, and to handle the edge case where start is exactly the last valid date/time before the window.
  • Loading branch information
logiclrd committed Apr 1, 2021
1 parent 4660f9c commit 50b2b1f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Source/Bogus/DataSets/Date.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,20 @@ private void ComputeRealRange(ref DateTime start, ref DateTime end)
#if !NETSTANDARD1_3
var window = GetForwardDSTTransitionWindow(start);

if ((start > window.Start) && (start <= window.End))
start = new DateTime(window.End.Ticks, start.Kind);
if ((start >= window.Start) && (start <= window.End))
{
if ((start == window.Start) && (end >= window.Start) && (end <= window.End))
end = start;
else
start = new DateTime(window.End.Ticks, start.Kind);

if (start == end)
return;
}

window = GetForwardDSTTransitionWindow(end);

if ((end >= window.Start) && (end < window.End))
if ((end >= window.Start) && (end <= window.End))
end = new DateTime(window.Start.Ticks, end.Kind);

if (start > end)
Expand Down

0 comments on commit 50b2b1f

Please sign in to comment.