Add n business days to a given date ignoring holidays and weekends in python

前端 未结 11 632
天涯浪人
天涯浪人 2020-12-05 10:32

I\'m trying to add n (integer) working days to a given date, the date addition has to avoid the holidays and weekends (it\'s not included in the working days)

11条回答
  •  独厮守ぢ
    2020-12-05 11:07

    This will take some work since there isn't any defined construct for holidays in any library (by my knowledge at least). You will need to create your own enumeration of those.

    Checking for weekend days is done easily by calling .weekday() < 6 on your datetime object.

提交回复
热议问题