Skip to content

Commit 5381c8c

Browse files
committed
Fix calculation where a date loses a timezone
closes #45
1 parent 1a3fd20 commit 5381c8c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

doc/changelog.rst

+8-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ v0.12.0
55
-------
66

77
API Changes
8-
-----------
8+
***********
9+
910
- mizani now requires python 3.9 and above.
1011

12+
Bug Fixes
13+
*********
14+
15+
- Fixed bug where a date with a timezone could lose the timezone. :issue:`45`.
16+
17+
1118
v0.11.4
1219
-------
1320
*2024-05-24*

mizani/_core/date_utils.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,11 @@ def floor_day(d: datetime) -> datetime:
291291
"""
292292
Round down to the start of the day
293293
"""
294-
return d.min.replace(d.year, d.month, d.day) if has_time(d) else d
294+
return (
295+
d.min.replace(d.year, d.month, d.day, tzinfo=d.tzinfo)
296+
if has_time(d)
297+
else d
298+
)
295299

296300

297301
def ceil_day(d: datetime) -> datetime:

0 commit comments

Comments
 (0)