botant / py-business-calendar

Business days and custom calendar calculations for Python
MIT License
26 stars 11 forks source link

Calendar.busdaycount(date1, date2) crashes when date1 is a last known holiday #4

Closed stebunovd closed 4 years ago

stebunovd commented 7 years ago
Python 3.6.1 (default, Mar 23 2017, 02:14:56) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import date                                          
>>> from business_calendar import Calendar                             
>>> calendar = Calendar(holidays=[date(2017, 7, 4)])        
>>> calendar.busdaycount(date(2017, 7, 4), date(2017, 7, 5))
__main__:1: CalendarHolidayWarning: Holiday list exhausted at end, busdaycount(2017-07-04,2017-07-05) output may be incorrect.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/business_calendar/business_calendar.py", line 522, in busdaycount
    while holidays[i] <= date2:
IndexError: list index out of range
>>>
botant commented 4 years ago

Fixed in version 1.0.