Commit 920acd3e authored by Kristian Tan's avatar Kristian Tan

Displaying daily total on html

parent bf9be05b
...@@ -2,7 +2,7 @@ from flask import Flask, render_template ...@@ -2,7 +2,7 @@ from flask import Flask, render_template
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
import os import os
from datetime import datetime, date from datetime import datetime, date, timedelta
# from daily_usage import DailyUsage # from daily_usage import DailyUsage
app = Flask(__name__) app = Flask(__name__)
...@@ -113,10 +113,11 @@ def toggle_pin(change_pin): ...@@ -113,10 +113,11 @@ def toggle_pin(change_pin):
if latest_entry: if latest_entry:
latest_entry_date = date(latest_entry.date.year, latest_entry.date.month, latest_entry.date.day) latest_entry_date = date(latest_entry.date.year, latest_entry.date.month, latest_entry.date.day)
if latest_entry_date == datetime.today().date(): if latest_entry_date == datetime.today().date():
daily_total = latest_entry.on_time_seconds daily_total = timedelta(seconds=latest_entry.on_time_seconds)
else: else:
daily_total = 0 daily_total = 0
template_data = { template_data = {
'message': message, 'message': message,
'pins': pins, 'pins': pins,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment