Make dateparser timezone aware
This commit is contained in:
parent
3b9a3f721b
commit
46693f2443
1 changed files with 5 additions and 6 deletions
|
@ -102,7 +102,7 @@ class RemindmeCog(Scale):
|
|||
base_settings = {
|
||||
"PREFER_DATES_FROM": "future",
|
||||
"TIMEZONE": "UTC",
|
||||
"RETURN_AS_TIMEZONE_AWARE": False,
|
||||
"RETURN_AS_TIMEZONE_AWARE": True,
|
||||
}
|
||||
rt_settings = base_settings.copy()
|
||||
rt_settings["PARSERS"] = [
|
||||
|
@ -115,12 +115,11 @@ class RemindmeCog(Scale):
|
|||
at_settings["PARSERS"] = [x for x in default_parsers if x != "relative-time"]
|
||||
at_remind_at = parse(delay, settings=at_settings)
|
||||
|
||||
if rt_remind_at and at_remind_at:
|
||||
remind_at = max(rt_remind_at, at_remind_at)
|
||||
if rt_remind_at:
|
||||
remind_at = rt_remind_at
|
||||
elif at_remind_at:
|
||||
remind_at = at_remind_at
|
||||
else:
|
||||
remind_at = rt_remind_at or at_remind_at
|
||||
|
||||
if not remind_at:
|
||||
self.logger.debug(f"Failed to parse delay: {delay}")
|
||||
await response.send(
|
||||
f"`{delay}` is not a parsable date, please try again", ephemeral=True
|
||||
|
|
Loading…
Add table
Reference in a new issue