Skip to content

Commit

Permalink
force utc timezone for datetime.fromisoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
deronnax committed Apr 11, 2024
1 parent 79b4be1 commit e98349f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions iredis/completers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from typing import Iterable
from datetime import datetime
from datetime import datetime, timezone

from dateutil.relativedelta import relativedelta
from prompt_toolkit.completion import (
Expand Down Expand Up @@ -123,7 +123,7 @@ def _completion_humanize_time(self, document: Document) -> Iterable[Completion]:
def _completion_formatted_time(self, document: Document) -> Iterable[Completion]:
text = document.text
try:
dt = datetime.fromisoformat(text)
dt = datetime.fromisoformat(text).replace(tzinfo=timezone.utc)
except Exception:
return
yield Completion(
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/test_completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_timestamp_completer_datetime_format_time_completion():
text="1581033600000",
start_position=-10,
display=FormattedText([("", "1581033600000")]),
display_meta="2020-02-07T00:00:00+00:00",
display_meta="2020-02-07 00:00:00+00:00",
)
]

Expand Down

0 comments on commit e98349f

Please sign in to comment.