Skip to content

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

Python

Filename dates use the browser's IANA zone, so the offset is the one on the file's date across daylight-saving changes (#412 B9)

Murtaza Nasir42ad3b403d1e
diff --git a/src/api/recordings.py b/src/api/recordings.py
index f6fe4234..966a16a0 100644
--- a/src/api/recordings.py
+++ b/src/api/recordings.py
@@ -2681,6 +2681,7 @@ def ingest_uploaded_recording(
pattern_key=owner.filename_date_pattern or 'auto',
custom_regex=owner.filename_date_regex,
tz_offset_minutes=tz_offset,
+ tz_name=form.get('client_timezone'),
)
if meeting_date:
current_app.logger.info(f"Using filename-parsed meeting_date: {meeting_date}")
diff --git a/src/utils/filename_dates.py b/src/utils/filename_dates.py
index 6effbb9b..34117c69 100644
--- a/src/utils/filename_dates.py
+++ b/src/utils/filename_dates.py
@@ -91,7 +91,8 @@ def _has_time(groups) -> bool:
def parse_filename_date(filename: str, pattern_key: str = 'auto',
custom_regex: Optional[str] = None,
- tz_offset_minutes: Optional[int] = None) -> Optional[datetime]:
+ tz_offset_minutes: Optional[int] = None,
+ tz_name: Optional[str] = None) -> Optional[datetime]:
"""
Extract a meeting date from *filename* and return it as naive UTC.
@@ -138,7 +139,16 @@ def parse_filename_date(filename: str, pattern_key: str = 'auto',
if parsed is None:
continue
- # Local wall-clock -> naive UTC per the storage convention.
+ # Local wall-clock -> naive UTC per the storage convention. A named zone
+ # (the browser's IANA zone) gives the offset that applied on that date,
+ # across daylight-saving changes; the browser's current offset is the
+ # fallback (#412 B9).
+ if tz_name:
+ from src.utils.timezones import is_valid_timezone
+ if is_valid_timezone(tz_name):
+ from zoneinfo import ZoneInfo
+ from datetime import timezone as _utc
+ return parsed.replace(tzinfo=ZoneInfo(tz_name)).astimezone(_utc.utc).replace(tzinfo=None)
if tz_offset_minutes is not None:
try:
offset = int(tz_offset_minutes)
diff --git a/tests/test_filename_dates_dst.py b/tests/test_filename_dates_dst.py
new file mode 100644
index 00000000..aebd2566
--- /dev/null
+++ b/tests/test_filename_dates_dst.py
@@ -0,0 +1,30 @@
+"""Filename dates across a daylight-saving change (#412 B9).
+
+The browser sent only its current UTC offset, so a filename dated in summer,
+uploaded in winter, was converted with the winter offset: one hour off. The
+browser's IANA zone gives the offset that applied on the file's date.
+"""
+
+import os
+import sys
+from datetime import datetime
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from src.utils.filename_dates import parse_filename_date
+
+
+def test_named_zone_uses_the_offset_on_the_files_date():
+ # 16 Jul 2026 11:02 in New York is EDT (UTC-4) -> 15:02 UTC.
+ winter_offset = 300 # getTimezoneOffset() in January (EST)
+ assert parse_filename_date("20260716_1102.m4a", "yyyymmdd_hhmm", tz_offset_minutes=winter_offset,
+ tz_name="America/New_York") == datetime(2026, 7, 16, 15, 2)
+
+
+def test_offset_only_keeps_the_old_behaviour():
+ assert parse_filename_date("20260716_1102.m4a", "yyyymmdd_hhmm", tz_offset_minutes=300) == datetime(2026, 7, 16, 16, 2)
+
+
+def test_invalid_zone_falls_back_to_the_offset():
+ assert parse_filename_date("20260716_1102.m4a", "yyyymmdd_hhmm", tz_offset_minutes=300,
+ tz_name="Not/AZone") == datetime(2026, 7, 16, 16, 2)