Skip to content
Snippets Groups Projects
Commit 21e442a1 authored by morkolai's avatar morkolai
Browse files

#52 Fikset seconds_to_next_update() etter test

parent 98999377
No related branches found
No related tags found
1 merge request!27#52 Automatisk oppdatering av kodebok basert på tid
Pipeline #73884 failed
......@@ -205,22 +205,24 @@ class Database:
def seconds_to_next_update(self):
"""
Rerturns time to next updated of Codebook in seconds.
Rerturns time to next update of Codebook in seconds.
Returns
-------
time_diff : float
seconds_to_update : float
Time to next update in seconds
"""
stmt = "SELECT Timestamp FROM LastUpdated"
last_updated = self.conn.execute(stmt).fetchall()[0][0]
# Convert datetime string to datetime object
last_updated = datetime.strptime(last_updated, "%Y-%m-%d %H:%M:%S.%f")
date_and_time_now = datetime.now()
time_diff = date_and_time_now - last_updated
# Time difference in seconds
time_diff = time_diff.total_seconds()
return time_diff
# 24h in seconds minus the difference of the last update time and
# current time in seconds makes the current number of seconds
# til next update.
seconds_to_update = (24 * 60 * 60) - (
datetime.now() - last_updated
).total_seconds()
return seconds_to_update
def add_code_to(self, word, mode="ascii"):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment