Skip to content

Commit

Permalink
Correct control flow in strftime
Browse files Browse the repository at this point in the history
  • Loading branch information
menzenski committed Jan 31, 2023
1 parent fbc27a7 commit 7ee2b3a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions singer_sdk/_singerlib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ def strftime(dtime: datetime, format_str: str = DATETIME_FMT) -> str:
if dtime.utcoffset() != timedelta(0):
raise Exception("datetime must be pegged at UTC tzoneinfo")

dt_str = None
try:
dt_str = dtime.strftime(format_str)
if dt_str.startswith("4Y"):
return dtime.strftime(DATETIME_FMT_SAFE)
dt_str = dtime.strftime(DATETIME_FMT_SAFE)
except ValueError:
return dtime.strftime(DATETIME_FMT_SAFE)
dt_str = dtime.strftime(DATETIME_FMT_SAFE)
return dt_str

0 comments on commit 7ee2b3a

Please # to comment.