import datetime

def do_duration(db, path):
    start = db.query("general/start")
    end = db.query("general/end")
    dtstart = datetime.datetime.strptime(start, "%Y-%m-%d %H:%M:%S")
    dtend = datetime.datetime.strptime(end, "%Y-%m-%d %H:%M:%S")
    return str(dtend-dtstart)

def do_loop(db, path):
    return db.query(path)

def init(db):
    db.add_dynamic("general/duration", do_duration)
    db.add_dynamic("general/loop", do_loop)
