diff options
author | Yobmod <yobmod@gmail.com> | 2021-08-02 16:54:31 +0100 |
---|---|---|
committer | Yobmod <yobmod@gmail.com> | 2021-08-02 16:54:31 +0100 |
commit | 2fe13cad9c889b8628119ab5ee139038b0c164fd (patch) | |
tree | 68627e17797d8725e05750e334237e6f2fbebaf9 /git/objects/util.py | |
parent | 730f11936364314b76738ed06bdd9222dc9de2ac (diff) | |
download | gitpython-2fe13cad9c889b8628119ab5ee139038b0c164fd.tar.gz |
Fix parse_date typing 3
Diffstat (limited to 'git/objects/util.py')
-rw-r--r-- | git/objects/util.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/git/objects/util.py b/git/objects/util.py index e3e7d3ba..6e3f688e 100644 --- a/git/objects/util.py +++ b/git/objects/util.py @@ -181,13 +181,11 @@ def parse_date(string_date: Union[str, datetime]) -> Tuple[int, int]: :raise ValueError: If the format could not be understood :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY. """ - if isinstance(string_date, datetime): - if string_date.tzinfo and string_date.utcoffset(): - utcoffset = string_date.utcoffset() - offset = -int(utcoffset.total_seconds()) if utcoffset else 0 - else: - offset = 0 + if isinstance(string_date, datetime) and string_date.tzinfo: + utcoffset = string_date.utcoffset() + offset = -int(utcoffset.total_seconds()) if utcoffset else 0 return int(string_date.astimezone(utc).timestamp()), offset + else: assert isinstance(string_date, str), f"string_date={string_date}, type={type(string_date)}" # for mypy |