Fix timezone to Sydney
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user