Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Remove now-dead local_datetime_filter (defs, imports, re-exports, unused pytz/babel imports); note TIMEZONE display change in v0.9.0 release notes

Murtaza Nasirfd432db0f4d4
diff --git a/release_notes_v0.9.0.md b/release_notes_v0.9.0.md
index 624df14b..bcdb1845 100644
--- a/release_notes_v0.9.0.md
+++ b/release_notes_v0.9.0.md
@@ -86,4 +86,6 @@ Full translation coverage refreshed across the seven supported languages (Englis
Backwards compatible with v0.8.x. Database migrations run automatically on startup. Existing recordings, tags, folders, groups, and shares are unaffected. Webhook system is opt-in (no webhooks fire until you create a subscription). Recording sessions are an internal backend change with no client-visible behaviour difference except for the longer max-recording ceiling.
+Timezone behaviour change (no migration): in-app timestamps now render in each viewer's own browser timezone instead of the server's `TIMEZONE` setting. Timestamps are stored unchanged (naive UTC) and served as UTC ISO; the browser localises them. The `TIMEZONE` environment variable therefore no longer affects in-app display (it is now effectively a no-op and harmless if left set). Single-timezone deployments where `TIMEZONE` already matched users' zones will see no visible difference.
+
Browser support note: full system audio recording requires Chrome or Edge on Windows or ChromeOS. macOS and Linux can capture tab audio out of the box and full system audio via the documented virtual-audio-device workflows. Firefox and Safari can transcribe uploaded audio but cannot capture screen audio via `getDisplayMedia`.
diff --git a/src/app.py b/src/app.py
index 1e52fa36..f2c1b69e 100644
--- a/src/app.py
+++ b/src/app.py
@@ -38,8 +38,6 @@ from wtforms import StringField, PasswordField, SubmitField, BooleanField
from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
-import pytz
-from babel.dates import format_datetime
import ast
import logging
import secrets
@@ -417,7 +415,7 @@ from src.models import (
# Import utility functions from extracted modules
from src.utils import (
auto_close_json, safe_json_loads, preprocess_json_escapes, extract_json_object,
- md_to_html, sanitize_html, local_datetime_filter, password_check,
+ md_to_html, sanitize_html, password_check,
add_column_if_not_exists, is_safe_url
)
@@ -565,31 +563,6 @@ def inject_group_admin_status():
return {'is_group_admin': is_group_admin}
-# --- Timezone Formatting Filter ---
[email protected]_filter('localdatetime')
-def local_datetime_filter(dt):
- """Format a UTC datetime object to the user's local timezone."""
- if dt is None:
- return ""
-
- # Get timezone from .env, default to UTC
- user_tz_name = os.environ.get('TIMEZONE', 'UTC')
- try:
- user_tz = pytz.timezone(user_tz_name)
- except pytz.UnknownTimeZoneError:
- user_tz = pytz.utc
- app.logger.warning(f"Invalid TIMEZONE '{user_tz_name}' in .env. Defaulting to UTC.")
-
- # If the datetime object is naive, assume it's UTC
- if dt.tzinfo is None:
- dt = pytz.utc.localize(dt)
-
- # Convert to the user's timezone
- local_dt = dt.astimezone(user_tz)
-
- # Format it nicely
- return format_datetime(local_dt, format='medium', locale='en_US')
-
# Ensure upload and instance directories exist
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
diff --git a/src/models/recording.py b/src/models/recording.py
index 55f7fa60..f7ecfcc3 100644
--- a/src/models/recording.py
+++ b/src/models/recording.py
@@ -9,7 +9,7 @@ import os
from datetime import datetime
from sqlalchemy import func
from src.database import db
-from src.utils import local_datetime_filter, md_to_html
+from src.utils import md_to_html
logger = logging.getLogger(__name__)
diff --git a/src/models/sharing.py b/src/models/sharing.py
index 7c2d9a34..b58282ba 100644
--- a/src/models/sharing.py
+++ b/src/models/sharing.py
@@ -9,7 +9,6 @@ import os
import secrets
from datetime import datetime
from src.database import db
-from src.utils import local_datetime_filter
# Get sharing configuration from environment
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
index 0c1bb3da..bab564e0 100644
--- a/src/utils/__init__.py
+++ b/src/utils/__init__.py
@@ -20,10 +20,6 @@ from .markdown import (
sanitize_html
)
-from .datetime import (
- local_datetime_filter
-)
-
from .security import (
password_check,
is_safe_url
@@ -58,8 +54,6 @@ __all__ = [
# Markdown/HTML
'md_to_html',
'sanitize_html',
- # Datetime
- 'local_datetime_filter',
# Security
'password_check',
'is_safe_url',
diff --git a/src/utils/datetime.py b/src/utils/datetime.py
deleted file mode 100644
index 28e21bc5..00000000
--- a/src/utils/datetime.py
+++ /dev/null
@@ -1,46 +0,0 @@
-"""
-Datetime utilities for timezone handling and formatting.
-
-This module provides functions for converting and formatting datetimes
-with timezone awareness.
-"""
-
-import os
-import logging
-import pytz
-from babel.dates import format_datetime
-
-# Module-level logger
-logger = logging.getLogger(__name__)
-
-
-def local_datetime_filter(dt):
- """
- Format a UTC datetime object to the user's local timezone.
-
- Args:
- dt: datetime object to format (assumed UTC if naive)
-
- Returns:
- str: Formatted datetime string in user's timezone
- """
- if dt is None:
- return ""
-
- # Get timezone from .env, default to UTC
- user_tz_name = os.environ.get('TIMEZONE', 'UTC')
- try:
- user_tz = pytz.timezone(user_tz_name)
- except pytz.UnknownTimeZoneError:
- user_tz = pytz.utc
- logger.warning(f"Invalid TIMEZONE '{user_tz_name}' in .env. Defaulting to UTC.")
-
- # If the datetime object is naive, assume it's UTC
- if dt.tzinfo is None:
- dt = pytz.utc.localize(dt)
-
- # Convert to the user's timezone
- local_dt = dt.astimezone(user_tz)
-
- # Format it nicely
- return format_datetime(local_dt, format='medium', locale='en_US')