Skip to content

Commit

Permalink
Impose upper bound on both ends of range
Browse files Browse the repository at this point in the history
Fixes #1171.
  • Loading branch information
victorlin committed Mar 29, 2023
1 parent 7a7d3b7 commit c4533b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion augur/dates/ambiguous_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def range(self):
resolve_uncertain_int(self.uncertain_date_components["d"], "max"),
)

# Limit the max date to be no later than today's date.
# Limit the min and max dates to be no later than today's date.
min_date = min(min_date, datetime.date.today())
max_date = min(max_date, datetime.date.today())

return (min_date, max_date)
Expand Down
5 changes: 2 additions & 3 deletions tests/dates/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ def test_get_numerical_date_from_value_ambiguous_month_and_day(self):
@freeze_time("2000-02-20")
def test_get_numerical_date_from_value_current_day_limit(self):
min_date, max_date = dates.get_numerical_date_from_value("2000-03-XX", "%Y-%m-%d")
# min_date is not subject to the upper limit
assert (min_date
== pytest.approx(dates.numeric_date(datetime.date(year=2000, month=3, day=1)), abs=1e-3)
== pytest.approx(2000.165, abs=1e-3)
== pytest.approx(dates.numeric_date(datetime.date(year=2000, month=2, day=20)), abs=1e-3)
== pytest.approx(2000.138, abs=1e-3)
)
assert (max_date
== pytest.approx(dates.numeric_date(datetime.date(year=2000, month=2, day=20)), abs=1e-3)
Expand Down

0 comments on commit c4533b0

Please sign in to comment.