From 5c444dccdc9c283b4d21dda40755736cbe6dc711 Mon Sep 17 00:00:00 2001 From: Ammar Abdelhalem Date: Sat, 29 Nov 2025 22:51:00 +0200 Subject: [PATCH 1/2] Fix naive datetime in RichHandler (refs #3877) --- rich/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rich/logging.py b/rich/logging.py index c3e7a5f670..31e4c8f296 100644 --- a/rich/logging.py +++ b/rich/logging.py @@ -224,7 +224,7 @@ def render( path = Path(record.pathname).name level = self.get_level_text(record) time_format = None if self.formatter is None else self.formatter.datefmt - log_time = datetime.fromtimestamp(record.created) + log_time = datetime.fromtimestamp(record.created).astimezone() log_renderable = self._log_render( self.console, From fe88964a395ee854cf4b4fb859d85cfcc57d2d1f Mon Sep 17 00:00:00 2001 From: Ammar Abdelhalem Date: Sat, 29 Nov 2025 23:00:06 +0200 Subject: [PATCH 2/2] add fix desc to CHANGELOG.md file and add my name to CONTRIBUTORS.md file --- CHANGELOG.md | 1 + CONTRIBUTORS.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e53205666f..d08c53ad36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed extraction of recursive exceptions https://github.com/Textualize/rich/pull/3772 - Fixed padding applied to Syntax https://github.com/Textualize/rich/pull/3782 - Fixed `Panel` title missing the panel background style https://github.com/Textualize/rich/issues/3569 +- Fixed RichHandler log time rendering by converting naive datetimes to timezone-aware to ensure correct display https://github.com/Textualize/rich/issues/3877 ### Added diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4b04786b9c..ba64328523 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -94,3 +94,4 @@ The following people have contributed to the development of Rich: - [Jonathan Helmus](https://github.com/jjhelmus) - [Brandon Capener](https://github.com/bcapener) - [Alex Zheng](https://github.com/alexzheng111) +- [Ammar Abdelhalem](https://github.com/ammarabdelhalem)