Skip to content

Commit 9a67dbc

Browse files
committed
Merge pull request #5911 from dorandeluz/bday-addition
BUG: dt+BDay(n) wrong if n>5, n%5==0 and dt not on offset (GH5890)
2 parents 252aa6c + 4b791d4 commit 9a67dbc

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

doc/source/release.rst

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Bug Fixes
8787
- Bug when assigning to .ix[tuple(...)] (:issue:`5896`)
8888
- Bug in fully reindexing a Panel (:issue:`5905`)
8989
- Bug in idxmin/max with object dtypes (:issue:`5914`)
90+
- Bug in ``BusinessDay`` when adding n days to a date not on offset when n>5 and n%5==0 (:issue:`5890`)
9091

9192
pandas 0.13.0
9293
-------------

pandas/tseries/offsets.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@ def apply(self, other):
397397
if n < 0 and result.weekday() > 4:
398398
n += 1
399399
n -= 5 * k
400-
400+
if n == 0 and result.weekday() > 4:
401+
n -= 1
402+
401403
while n != 0:
402404
k = n // abs(n)
403405
result = result + timedelta(k)

pandas/tseries/tests/test_offsets.py

+5
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ def test_apply_large_n(self):
317317
rs = st + off
318318
xp = datetime(2011, 12, 26)
319319
self.assertEqual(rs, xp)
320+
321+
off = BDay() * 10
322+
rs = datetime(2014, 1, 5) + off # see #5890
323+
xp = datetime(2014, 1, 17)
324+
self.assertEqual(rs, xp)
320325

321326
def test_apply_corner(self):
322327
self.assertRaises(TypeError, BDay().apply, BMonthEnd())

0 commit comments

Comments
 (0)