From abf5050ea700a06e4f0269d43297ba890efc0700 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 23 Sep 2026 15:00:48 -0700 Subject: [PATCH] Fix: convert file mtime to the configured time zone directly (#14249) The `created` date fallback derived a naive datetime from a file's mtime using the OS-local zone, then labeled it as the configured TIME_ZONE without converting. When the OS-local zone and TIME_ZONE disagree, or when the C library can't resolve zoneinfo at all (as in some sandboxed environments, where it silently falls back to UTC), the resulting date can land on the wrong calendar day. Convert the timestamp directly into the target zone with `tz=` on fromtimestamp() instead of a naive conversion plus make_aware(). --- src/documents/consumer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/documents/consumer.py b/src/documents/consumer.py index edb48c348..4f321d88e 100644 --- a/src/documents/consumer.py +++ b/src/documents/consumer.py @@ -857,8 +857,9 @@ class ConsumerPlugin( self.log.debug(f"Creation date from parse_date: {create_date}") else: stats = Path(self.input_doc.original_file).stat() - create_date = timezone.make_aware( - datetime.datetime.fromtimestamp(stats.st_mtime), + create_date = datetime.datetime.fromtimestamp( + stats.st_mtime, + tz=timezone.get_current_timezone(), ) self.log.debug(f"Creation date from st_mtime: {create_date}")