Skip to content

Commit

Permalink
Adjusted code
Browse files Browse the repository at this point in the history
  • Loading branch information
Inf-inity authored and Inf-inity committed Mar 30, 2023
1 parent 92786bf commit a1ea008
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions datetimeparser/evaluator/evaluatorutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,13 @@ def get_base(self, sanitized_input: list, year: int, current_time: datetime, for

return dt

else:
if sanitized_input[-3].value:
val: int = sanitized_input[-3].value
elif sanitized_input[-3].value:
val: int = sanitized_input[-3].value

if sanitized_input[-2].name == "days":
return datetime(sanitized_input[-1].year, 1, val, 0, 0, 0)
if sanitized_input[-2].name == "months":
return datetime(sanitized_input[-1].year, val, 1, 0, 0, 0)
if sanitized_input[-2].name == "days":
return datetime(sanitized_input[-1].year, 1, val, 0, 0, 0)
if sanitized_input[-2].name == "months":
return datetime(sanitized_input[-1].year, val, 1, 0, 0, 0)

# If a year is given but no months/days, they will be set to '1' because datetime can't handle month/day-values with '0'
if sanitized_input[-1].year != 0:
Expand Down

0 comments on commit a1ea008

Please sign in to comment.