Skip to content

Commit 730f119

Browse files
committed
Fix parse_date typing 2
1 parent 13e0730 commit 730f119

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

git/objects/util.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]:
182182
:note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY.
183183
"""
184184
if isinstance(string_date, datetime):
185-
if string_date.tzinfo:
185+
if string_date.tzinfo and string_date.utcoffset():
186186
utcoffset = string_date.utcoffset()
187187
offset = -int(utcoffset.total_seconds()) if utcoffset else 0
188+
else:
189+
offset = 0
188190
return int(string_date.astimezone(utc).timestamp()), offset
189191
else:
190192
assert isinstance(string_date, str), f"string_date={string_date}, type={type(string_date)}" # for mypy

0 commit comments

Comments
 (0)