Skip to content

Commit

Permalink
Start with a big jump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corniel committed Mar 10, 2024
1 parent 1cfaf58 commit cc3e25a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions specs/Qowaiv.Specs/Month_span_specs.cs
Expand Up @@ -92,6 +92,7 @@ public void decrement()

public class Can_subtract
{
[TestCase("2020-04-30", "1710-02-01", "310Y+2M")]
[TestCase("2020-04-30", "2020-04-01", 00)]
[TestCase("2020-04-30", "2020-03-31", 01)]
[TestCase("2020-01-01", "2019-01-02", 11)]
Expand All @@ -102,6 +103,7 @@ public void two_dates(Date d1, Date d2, MonthSpan expected)
=> MonthSpan.Subtract(d1, d2).Should().Be(expected);

#if NET6_0_OR_GREATER
[TestCase("2020-04-30", "1710-02-01", "310Y+2M")]
[TestCase("2020-04-30", "2020-04-01", 00)]
[TestCase("2020-04-30", "2020-03-31", 01)]
[TestCase("2020-01-01", "2019-01-02", 11)]
Expand Down
8 changes: 4 additions & 4 deletions src/Qowaiv/MonthSpan.cs
Expand Up @@ -332,13 +332,13 @@ public static MonthSpan Subtract(Date d1, Date d2)

if (negative)
{
max = d2;
min = d1;
(min, max) = (max, min);
}

var test = min;
var years = Math.Max(0, max.Year - min.Year - 1);
var months = years * 12;

var months = 0;
var test = min.AddYears(years);

while (test < max)
{
Expand Down

0 comments on commit cc3e25a

Please sign in to comment.