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,7 +1,10 @@
from datetime import datetime, timezone, timedelta
from flask import Flask
from app.config import Config
from app.db import init_db, close_db
SYDNEY_TZ = timezone(timedelta(hours=11))
def create_app():
app = Flask(__name__)
@@ -11,6 +14,15 @@ def create_app():
init_db(app)
app.teardown_appcontext(close_db)
# Jinja2 filter: convert UTC to Sydney time
@app.template_filter('sydney')
def sydney_time_filter(dt, fmt='%d %b %Y, %H:%M'):
if dt is None:
return ''
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
return dt.astimezone(SYDNEY_TZ).strftime(fmt)
# Register blueprints
from app.routes.auth import bp as auth_bp
from app.routes.dashboard import bp as dashboard_bp