You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks a lot for writing and maintaining pendulum!
While playing around with a couple of edge cases, I seem to have stumbled upon a bug in DateTime.subtract() and either a bug or my misunderstanding about the way DateTime.add(days=N) should work across a DST change. I'm attaching a Python source test file (test_sofia_dst.txt) that uses pytest.mark.parametrize() to get closer and closer to the DST change time for Sofia, Bulgaria, earlier this year.
The subtraction problems
Starting from a timestamp in mid-August 24, and subtracting several different time intervals from it, I expected to get exactly to
the time after the DST change (04:00:00 on 2024-03-31) and then, subtracting an interval a second longer, to get to the time just before the DST change (02:59:59 on 2024-03-31). The 04:59:59 result surprised me, as did the result of subtracting a longer interval.
This is the short output from pytest. The values on the right are the ones I expected to get.
I'm not sure if .add(days=N) is supposed to add 24-hour periods across a DST change, or merely increment the date; it seems to do the latter, but maybe that is intended behavior.
Issue
First of all, thanks a lot for writing and maintaining pendulum!
While playing around with a couple of edge cases, I seem to have stumbled upon a bug in
DateTime.subtract()
and either a bug or my misunderstanding about the wayDateTime.add(days=N)
should work across a DST change. I'm attaching a Python source test file (test_sofia_dst.txt) that usespytest.mark.parametrize()
to get closer and closer to the DST change time for Sofia, Bulgaria, earlier this year.The subtraction problems
Starting from a timestamp in mid-August 24, and subtracting several different time intervals from it, I expected to get exactly to
the time after the DST change (04:00:00 on 2024-03-31) and then, subtracting an interval a second longer, to get to the time just before the DST change (02:59:59 on 2024-03-31). The 04:59:59 result surprised me, as did the result of subtracting a longer interval.
This is the short output from pytest. The values on the right are the ones I expected to get.
The possible addition problem
I'm not sure if
.add(days=N)
is supposed to add 24-hour periods across a DST change, or merely increment the date; it seems to do the latter, but maybe that is intended behavior.If something goes wrong with these files, they are also available in a GitLab repository.
Thanks in advance for your time, apologies if this is actually a duplicate report, and keep up the great work!
G'luck,
Peter
The text was updated successfully, but these errors were encountered: