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

#52 Laget funskjon som bergner tid i sek til neste oppdatering

parent 21f3ac13
No related branches found
No related tags found
1 merge request!27#52 Automatisk oppdatering av kodebok basert på tid
Pipeline #73875 passed
......@@ -203,6 +203,25 @@ class Database:
print("Code in CodeBook updated")
def seconds_to_next_update(self):
"""
Rerturns time to next updated of Codebook in seconds.
Returns
-------
time_diff : 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
def add_code_to(self, word, mode="ascii"):
"""
Generate and insert a code for the new word in DB-table CodeBook.
......
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