Fix timezone to Sydney

This commit is contained in:
Peter Stockings
2026-02-23 08:32:18 +11:00
parent fc94d54d79
commit d6885a8339
4 changed files with 19 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
from flask import Blueprint, jsonify
from app import SYDNEY_TZ
from app.auth import login_required
from app.db import query
from datetime import timezone
bp = Blueprint("api", __name__, url_prefix="/api")
@@ -16,7 +18,7 @@ def chart_data(user_id):
(user_id,),
)
labels = [c["checked_in_at"].strftime("%d %b") for c in checkins]
labels = [c["checked_in_at"].replace(tzinfo=timezone.utc).astimezone(SYDNEY_TZ).strftime("%d %b") for c in checkins]
weights = [float(c["weight_kg"]) for c in checkins]
bmis = [float(c["bmi"]) if c["bmi"] else None for c in checkins]
@@ -88,7 +90,7 @@ def weekly_change(user_id):
prev_w = float(checkins[i - 1]["weight_kg"])
curr_w = float(checkins[i]["weight_kg"])
change = round(curr_w - prev_w, 1)
label = checkins[i]["checked_in_at"].strftime("%d %b")
label = checkins[i]["checked_in_at"].replace(tzinfo=timezone.utc).astimezone(SYDNEY_TZ).strftime("%d %b")
labels.append(label)
changes.append(change)