LKI / chinese-calendar

判断一天是不是法定节假日/法定工作日(查看节假日安排)
https://pypi.org/project/chinesecalendar/
MIT License
1.06k stars 185 forks source link

不调休判断假日与周末 #53

Closed shiba2046 closed 4 years ago

shiba2046 commented 4 years ago

金融行业中,就算是因为调休周末需要工作时,也是休息,不工作的。能否加个参数来忽略周末调休的情况?

比如 2020年2月1日:

chinese_calendar.is_holiday(datetime.date(2020,2,1))
False

实际这是一个周六,也是假日。

LKI commented 4 years ago

这个目前可以用内置的 datetime.date.isoweekday 来判断 比如:

import datetime
import chinese_calendar

date = datetime.date(2020,2,1)
is_holiday = chinese_calendar.is_holiday(date)
is_weekend = date.isoweekday() >= 6
if is_holiday or is_weekend:
    print("可以休息")
else:
    print("需要工作")