wilsonfreitas / python-bizdays

Business days calculations and utilities
http://wilsonfreitas.github.io/python-bizdays/
MIT License
80 stars 34 forks source link

offset method #5

Closed wilsonfreitas closed 11 years ago

wilsonfreitas commented 11 years ago

A offset method should be implemented.

cal.offset('2012-01-03', 6)
# returns the the date offset by 6, considering only the business days
# or
cal.offset('2012-01-03', -6)
# offset backward

it can be done with adjust_next and adjust_previous

wilsonfreitas commented 11 years ago

Calendar's offset method implemented

cal = Calendar('Test')
self.assertEqual(cal.offset('2013-01-02', 1), '2013-01-03')
self.assertEqual(cal.offset('2013-01-02', 3), '2013-01-07')
self.assertEqual(cal.offset('2013-01-01', 1), '2013-01-03')
self.assertEqual(cal.offset('2013-01-01', 0), '2013-01-02')
self.assertEqual(cal.offset('2013-01-02', 0), '2013-01-02')
self.assertEqual(cal.offset('2013-01-02', -1), '2012-12-31')
self.assertEqual(cal.offset('2013-01-02', -3), '2012-12-27')
self.assertEqual(cal.offset('2013-01-01', -1), '2012-12-28')