X-Git-Url: https://plomlompom.com/repos/do_day?a=blobdiff_plain;f=energy_tracker.py;h=444da172c3683d12e69d35b40d23fd605bd8c18e;hb=cf116472e137d4fcbcf6ce909de05ef75fb984f8;hp=204b582cd25a2b66c0dd4bc103ff508ebc530446;hpb=ed1cc7a1f866f5cc8bb039e93747118c7fcb9fce;p=misc
diff --git a/energy_tracker.py b/energy_tracker.py
index 204b582..444da17 100644
--- a/energy_tracker.py
+++ b/energy_tracker.py
@@ -15,10 +15,16 @@ def build_page(entries):
""" + f"""
@@ -73,7 +79,12 @@ class MyServer(BaseHTTPRequestHandler):
length = int(self.headers['content-length'])
postvars = parse_qs(self.rfile.read(length), keep_blank_values=1)
db = Database()
- db.entries[str(datetime.datetime.now())[:19]] = [int(postvars[b'energy'][0].decode()), postvars[b'comment'][0].decode()]
+ for val in ('---', '--', '-', '+', '++', '+++'):
+ val_name = 'energy ' + val
+ if val_name.encode() in postvars.keys():
+ time = datetime.datetime.now() - datetime.timedelta(minutes=int(postvars[b'backdate'][0].decode()))
+ db.entries[str(time)[:19]] = [val, postvars[b'comment'][0].decode()]
+ break
try:
db.write()
self.send_response(302)