Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
dachosen1 committed Nov 1, 2024
1 parent 9404912 commit ee9ae7b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nearquake/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,18 @@ def backfill_valid_date_range(start_date, end_date, interval: int) -> tuple:
:param end_date: The end date in "YYYY-MM-DD" format.
:param interval: The interval in days between each date in the range
:return: A list or iterable of dates from start_date to end_date with the specified interval.
:return: A tuple of date ranges from start_date to end_date with the specified interval
"""

try:
datetime.strptime(start_date, "%Y-%m-%d").date()
datetime.strptime(end_date, "%Y-%m-%d").date()
start = datetime.strptime(start_date, "%Y-%m-%d").date()
end = datetime.strptime(end_date, "%Y-%m-%d").date()

if start >= end:
raise ValueError("start_date must be before end_date")
if interval <= 0:
raise ValueError("interval must be positive")

except ValueError:
raise ValueError("Invalid date format. Use YYYY-MM-DD.")

Expand Down

0 comments on commit ee9ae7b

Please sign in to comment.