Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import datetime
from typing import Optional

def get_current_time_formatted() -> Optional[str]:
"""
Returns the current time as a formatted string in HH:MM:SS format.

Returns:
Optional[str]: The current time as a formatted string, or None if an error occurs.
"""
try:
current_time = datetime.datetime.now(datetime.timezone.utc)
formatted_time = current_time.strftime('%H:%M:%S')
return formatted_time
except Exception as e:
print(f"An error occurred while formatting the current time: {e}")
return None