botant / py-business-calendar

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

Bug: busdaycount() crashes with IndexError if holiday-list contains only the start date and start date is a busday #9

Open truderung opened 4 years ago

truderung commented 4 years ago

this fails:

start = "2019-12-31"
end = "2020-01-07"
Calendar(holidays=["2019-12-31"]).busdaycount(start, end)

but not if:

  start = "2019-12-31"
  end = "2020-01-07"
  Calendar(workdays=[MO, WE], holidays=["2019-12-31"]).busdaycount(start, end)

note: 2019-12-31 is TU 2020-01-01 is WE ... 2020-01-04 is SA ... 2020-01-07 is TU

truderung commented 4 years ago

It also crashes if holiday-list consists of the start date and other non-busdays:

  start = "2019-12-31"
  end = "2020-01-07"
  Calendar(holidays=["2019-12-31", "2020-01-04"]).busdaycount(start, end)

or

  start = "2019-12-31"
  end = "2020-01-07"
  Calendar(holidays=["2019-12-31", "2020-01-04"]).busdaycount(start, end)