Skip to content

Commit 32db310

Browse files
committed
remove excpetion handling in format_timestamp
also add a better docstring
1 parent c850da3 commit 32db310

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

infrahub_sdk/ctl/branch.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@
2525

2626

2727
def format_timestamp(timestamp: str) -> str:
28-
"""Format ISO timestamp to 'YYYY-MM-DD HH:MM:SS'."""
29-
try:
30-
dt = datetime.fromisoformat(timestamp.replace("Z", "+00:00"))
31-
return dt.strftime("%Y-%m-%d %H:%M:%S")
32-
except (ValueError, AttributeError):
33-
return timestamp
28+
"""Format ISO timestamp to 'YYYY-MM-DD HH:MM:SS'.
29+
Args:
30+
timestamp (str): ISO fromatted timestamp
31+
32+
Returns:
33+
(str): the datetime as string formatted as 'YYYY-MM-DD HH:MM:SS'
34+
35+
Raises:
36+
Any execptions returned from formatting the timestamp are propogated to the caller
37+
"""
38+
dt = datetime.fromisoformat(timestamp.replace("Z", "+00:00"))
39+
return dt.strftime("%Y-%m-%d %H:%M:%S")
3440

3541

3642
async def check_git_files_changed(client: "InfrahubClient", branch: str) -> bool:

0 commit comments

Comments
 (0)