Skip to content

Commit a7400a7

Browse files
committed
Fix an error when adding an interval to a pendulum instance across DST transition
1 parent 5cb910b commit a7400a7

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [Unreleased]
4+
5+
### Fixed
6+
7+
- Fixed an error when adding intervals to a Pendulum instance across DST transition.
8+
9+
310
## [1.4.2] - 2018-02-22
411

512
### Fixed

pendulum/pendulum.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,8 +1233,7 @@ def add_timedelta(self, delta):
12331233
seconds=delta.remaining_seconds, microseconds=delta.microseconds
12341234
)
12351235

1236-
return self.add(days=delta.days, seconds=delta.seconds,
1237-
microseconds=delta.microseconds)
1236+
return self.add(seconds=delta.total_seconds())
12381237

12391238
def subtract_timedelta(self, delta):
12401239
"""

tests/pendulum_tests/test_add.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,9 @@ def test_add_time_to_new_transition_does_not_use_transition_rule(self):
236236
self.assertEqual('Europe/Paris', dt.timezone_name)
237237
self.assertEqual(7200, dt.offset)
238238
self.assertTrue(dt.is_dst)
239+
240+
def test_add_interval(self):
241+
dt = pendulum.create(2017, 3, 11, 10, 45, tz='America/Los_Angeles')
242+
new = dt + pendulum.interval(hours=24)
243+
244+
self.assertPendulum(new, 2017, 3, 12, 11, 45)

0 commit comments

Comments
 (0)