Ashhar commited on
Commit
4a987af
1 Parent(s): 36bcbee

fixed timestamp

Browse files
Files changed (1) hide show
  1. helpers/sidebar.py +9 -1
helpers/sidebar.py CHANGED
@@ -3,6 +3,12 @@ import datetime as DT
3
  from helpers.activities import resetActivity, restoreUserActivity, ActivityLogs
4
  import constants as C
5
  import utils as U
 
 
 
 
 
 
6
 
7
 
8
  def showSidebar():
@@ -84,7 +90,9 @@ def showSidebar():
84
  """)
85
  with st.container(height=300, border=False):
86
  for log in userActivityLogs:
87
- updatedAt = DT.datetime.fromisoformat(log["updated_at"].replace("Z", "+00:00"))
 
 
88
  localTime = updatedAt.astimezone().strftime("%b %d, %I:%M %p")
89
  activityId = log["id"]
90
  if st.button(f"Saved ⌛ {localTime}", key=f"activity_{activityId}", use_container_width=True):
 
3
  from helpers.activities import resetActivity, restoreUserActivity, ActivityLogs
4
  import constants as C
5
  import utils as U
6
+ import re
7
+
8
+
9
+ def __fixTimestamp(timestamp: str):
10
+ # Add a trailing zero to microseconds if needed
11
+ return re.sub(r'(\d{2}:\d{2}:\d{2}\.\d{5})(?=[+-]|$)', r'\g<1>0', timestamp)
12
 
13
 
14
  def showSidebar():
 
90
  """)
91
  with st.container(height=300, border=False):
92
  for log in userActivityLogs:
93
+ updatedAt = DT.datetime.fromisoformat(__fixTimestamp(
94
+ log["updated_at"].replace("Z", "+00:00")
95
+ ))
96
  localTime = updatedAt.astimezone().strftime("%b %d, %I:%M %p")
97
  activityId = log["id"]
98
  if st.button(f"Saved ⌛ {localTime}", key=f"activity_{activityId}", use_container_width=True):