Spaces:
Running
Running
update time
Browse files- .github/workflows/actions.yml +5 -0
- app.py +1 -1
- time_handling.py +6 -7
.github/workflows/actions.yml
CHANGED
@@ -27,6 +27,11 @@ jobs:
|
|
27 |
python -m pip install --upgrade pip
|
28 |
pip install -r requirements.txt
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
- name: Run update script
|
31 |
env:
|
32 |
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
|
|
27 |
python -m pip install --upgrade pip
|
28 |
pip install -r requirements.txt
|
29 |
|
30 |
+
- name: Set timezone
|
31 |
+
uses: szenius/[email protected]
|
32 |
+
with:
|
33 |
+
timezoneLinux: "Europe/Stockholm"
|
34 |
+
|
35 |
- name: Run update script
|
36 |
env:
|
37 |
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
|
app.py
CHANGED
@@ -156,7 +156,7 @@ def main():
|
|
156 |
last_update_dt = datetime.strptime(last_update, DATE_FORMAT)
|
157 |
st.markdown("### Database Status")
|
158 |
st.markdown("🔄 Updates every 6 hours")
|
159 |
-
st.markdown(f"**Last update:**{last_update_dt.strftime('%B %d, %Y at %I:%M %p')}")
|
160 |
except Exception as e:
|
161 |
st.error(f"Error reading timestamp: {str(e)}")
|
162 |
|
|
|
156 |
last_update_dt = datetime.strptime(last_update, DATE_FORMAT)
|
157 |
st.markdown("### Database Status")
|
158 |
st.markdown("🔄 Updates every 6 hours")
|
159 |
+
st.markdown(f"**Last update:**{last_update_dt.strftime('%B %d, %Y at %I:%M %p')} (Stockholm Time)")
|
160 |
except Exception as e:
|
161 |
st.error(f"Error reading timestamp: {str(e)}")
|
162 |
|
time_handling.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import sys
|
2 |
-
|
3 |
from datetime import datetime
|
|
|
4 |
import logging
|
5 |
|
6 |
from settings import LOG_LEVEL, LOG_DATE_FORMAT, LOG_FORMAT, DATE_FORMAT, TIMESTAMP_FILE
|
@@ -8,14 +8,14 @@ from settings import LOG_LEVEL, LOG_DATE_FORMAT, LOG_FORMAT, DATE_FORMAT, TIMEST
|
|
8 |
log = logging.getLogger(__name__)
|
9 |
logging.basicConfig(stream=sys.stdout, level=LOG_LEVEL, format=LOG_FORMAT, datefmt=LOG_DATE_FORMAT)
|
10 |
|
|
|
|
|
11 |
|
12 |
def elapsed_time(start):
|
13 |
-
return datetime.now() - start
|
14 |
-
|
15 |
|
16 |
def timestamp_now():
|
17 |
-
return datetime.now().strftime(DATE_FORMAT)
|
18 |
-
|
19 |
|
20 |
def write_timestamp(timestamp=None):
|
21 |
if not timestamp:
|
@@ -25,8 +25,7 @@ def write_timestamp(timestamp=None):
|
|
25 |
log.info(f"New timestamp written: {timestamp}")
|
26 |
return timestamp
|
27 |
|
28 |
-
|
29 |
def read_timestamp():
|
30 |
with open(file=TIMESTAMP_FILE, mode='r') as f:
|
31 |
timestamp = f.read()
|
32 |
-
return timestamp.strip('\n')
|
|
|
1 |
import sys
|
|
|
2 |
from datetime import datetime
|
3 |
+
from zoneinfo import ZoneInfo # Built-in since Python 3.9
|
4 |
import logging
|
5 |
|
6 |
from settings import LOG_LEVEL, LOG_DATE_FORMAT, LOG_FORMAT, DATE_FORMAT, TIMESTAMP_FILE
|
|
|
8 |
log = logging.getLogger(__name__)
|
9 |
logging.basicConfig(stream=sys.stdout, level=LOG_LEVEL, format=LOG_FORMAT, datefmt=LOG_DATE_FORMAT)
|
10 |
|
11 |
+
# Define Stockholm timezone
|
12 |
+
STOCKHOLM_TZ = ZoneInfo("Europe/Stockholm")
|
13 |
|
14 |
def elapsed_time(start):
|
15 |
+
return datetime.now(STOCKHOLM_TZ) - start
|
|
|
16 |
|
17 |
def timestamp_now():
|
18 |
+
return datetime.now(STOCKHOLM_TZ).strftime(DATE_FORMAT)
|
|
|
19 |
|
20 |
def write_timestamp(timestamp=None):
|
21 |
if not timestamp:
|
|
|
25 |
log.info(f"New timestamp written: {timestamp}")
|
26 |
return timestamp
|
27 |
|
|
|
28 |
def read_timestamp():
|
29 |
with open(file=TIMESTAMP_FILE, mode='r') as f:
|
30 |
timestamp = f.read()
|
31 |
+
return timestamp.strip('\n')
|