From 5158f0965ca889bd2db389642f5c2848019b3471 Mon Sep 17 00:00:00 2001 From: Christian Bahnweg Date: Wed, 7 Aug 2024 12:54:05 -0400 Subject: [PATCH 1/2] [BitBucket] Fix error with timezone formatting --- atlassian/bitbucket/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atlassian/bitbucket/base.py b/atlassian/bitbucket/base.py index b0292161e..fe1eafee5 100644 --- a/atlassian/bitbucket/base.py +++ b/atlassian/bitbucket/base.py @@ -164,7 +164,10 @@ def get_time(self, id): # The format contains a : in the timezone which is supported from 3.7 on. if sys.version_info <= (3, 7): value_str = RE_TIMEZONE.sub(r"\1\2", value_str) - value = datetime.strptime(value_str, self.CONF_TIMEFORMAT) + try: + value = datetime.strptime(value_str, self.CONF_TIMEFORMAT) + except ValueError: + value = datetime.strptime(value_str, %Y-%m-%dT%H:%M:%S.%fZ,tzinfo=UTC) else: value = value_str From 613489e20d19fa0f066cb6a6a8990926a500c041 Mon Sep 17 00:00:00 2001 From: Christian Bahnweg Date: Wed, 7 Aug 2024 17:50:05 -0400 Subject: [PATCH 2/2] reformat for black --- atlassian/bitbucket/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atlassian/bitbucket/base.py b/atlassian/bitbucket/base.py index fe1eafee5..f7b548aa6 100644 --- a/atlassian/bitbucket/base.py +++ b/atlassian/bitbucket/base.py @@ -167,7 +167,7 @@ def get_time(self, id): try: value = datetime.strptime(value_str, self.CONF_TIMEFORMAT) except ValueError: - value = datetime.strptime(value_str, %Y-%m-%dT%H:%M:%S.%fZ,tzinfo=UTC) + value = datetime.strptime(value_str, "%Y-%m-%dT%H:%M:%S.%fZ", tzinfo="UTC") else: value = value_str