File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,8 @@ def apply(self, other):
329
329
if abs (n ) > 5 :
330
330
k = n // 5
331
331
result = result + timedelta (7 * k )
332
+ if n < 0 and result .weekday () > 4 :
333
+ n += 1
332
334
n -= 5 * k
333
335
334
336
while n != 0 :
Original file line number Diff line number Diff line change @@ -274,6 +274,16 @@ def test_apply_large_n(self):
274
274
result = dt + BDay (100 ) - BDay (100 )
275
275
self .assertEqual (result , dt )
276
276
277
+ off = BDay () * 6
278
+ rs = datetime (2012 , 1 , 1 ) - off
279
+ xp = datetime (2011 , 12 , 23 )
280
+ self .assertEqual (rs , xp )
281
+
282
+ st = datetime (2011 , 12 , 18 )
283
+ rs = st + off
284
+ xp = datetime (2011 , 12 , 26 )
285
+ self .assertEqual (rs , xp )
286
+
277
287
def test_apply_corner (self ):
278
288
self .assertRaises (Exception , BDay ().apply , BMonthEnd ())
279
289
You can’t perform that action at this time.
0 commit comments