Skip to content

Commit

Permalink
assume times without a date are always in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
lmaotrigine committed Dec 16, 2023
1 parent 0aaa8f8 commit 19be5c0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ async def convert(self, ctx: Context, argument: str) -> FriendlyTimeResult:
'or I just flat out did not understand what you meant. Sorry.'
)

dt = dt.replace(tzinfo=tzinfo)
if not status.hasTime:
# replace it with the current time
dt = dt.replace(
Expand All @@ -263,11 +264,15 @@ async def convert(self, ctx: Context, argument: str) -> FriendlyTimeResult:
microsecond=now.microsecond,
)

if status.hasTime and not status.hasDate and dt < now:
# if it's in the past, and it has a time but no date,
# assume it's for the next occurrence of that time
dt = dt + datetime.timedelta(days=1)
# if midnight is provided, just default to next day
if status.accuracy == pdt.pdtContext.ACU_HALFDAY:
dt = dt.replace(day=now.day + 1)
dt = dt + datetime.timedelta(days=1)

result = FriendlyTimeResult(dt.replace(tzinfo=tzinfo))
result = FriendlyTimeResult(dt)
remaining = ''

if begin in (0, 1):
Expand Down

0 comments on commit 19be5c0

Please sign in to comment.