Ashhar
commited on
Commit
•
618e6a8
1
Parent(s):
4a987af
time zone fix
Browse files- helpers/sidebar.py +5 -2
helpers/sidebar.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
import datetime as DT
|
|
|
3 |
from helpers.activities import resetActivity, restoreUserActivity, ActivityLogs
|
4 |
import constants as C
|
5 |
import utils as U
|
@@ -8,7 +9,9 @@ import re
|
|
8 |
|
9 |
def __fixTimestamp(timestamp: str):
|
10 |
# Add a trailing zero to microseconds if needed
|
11 |
-
|
|
|
|
|
12 |
|
13 |
|
14 |
def showSidebar():
|
@@ -93,7 +96,7 @@ def showSidebar():
|
|
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):
|
99 |
restoreUserActivity(log["id"])
|
|
|
1 |
import streamlit as st
|
2 |
import datetime as DT
|
3 |
+
from zoneinfo import ZoneInfo
|
4 |
from helpers.activities import resetActivity, restoreUserActivity, ActivityLogs
|
5 |
import constants as C
|
6 |
import utils as U
|
|
|
9 |
|
10 |
def __fixTimestamp(timestamp: str):
|
11 |
# Add a trailing zero to microseconds if needed
|
12 |
+
fixedTimestamp = re.sub(r'(\d{2}:\d{2}:\d{2}\.\d{5})(?=[+-]|$)', r'\g<1>0', timestamp)
|
13 |
+
U.pprint(f"{timestamp=} | {fixedTimestamp=}")
|
14 |
+
return fixedTimestamp
|
15 |
|
16 |
|
17 |
def showSidebar():
|
|
|
96 |
updatedAt = DT.datetime.fromisoformat(__fixTimestamp(
|
97 |
log["updated_at"].replace("Z", "+00:00")
|
98 |
))
|
99 |
+
localTime = updatedAt.astimezone(ZoneInfo("Asia/Kolkata")).strftime("%b %d, %I:%M %p IST")
|
100 |
activityId = log["id"]
|
101 |
if st.button(f"Saved ⌛ {localTime}", key=f"activity_{activityId}", use_container_width=True):
|
102 |
restoreUserActivity(log["id"])
|