def test_freezegun_date(self): today = datetime.date.today() self.assertTrue(isinstance(today, freezegun.api.FakeDate)) self.assertTrue(jpholiday.is_holiday(today)) self.assertTrue(isinstance(self.the_date, datetime.date)) self.assertTrue(jpholiday.is_holiday(self.the_date))
def test_original_holiday(self): """ 独自の休み """ class TestHoliday(jpholiday.registry.OriginalHoliday): def _is_holiday(self, date): if date == datetime.date(2020, 2, 3) or date == datetime.date( 2020, 2, 5): return True if date == datetime.date(2020, 2, 9): return True return False def _is_holiday_name(self, date): return '特別休暇' # 国民の休日 self.assertEqual(jpholiday.is_holiday_name(datetime.date(2020, 2, 3)), '特別休暇') self.assertEqual(jpholiday.is_holiday(datetime.date(2020, 2, 4)), False) self.assertEqual(jpholiday.is_holiday_name(datetime.date(2020, 2, 5)), '特別休暇') # 振替休日 self.assertEqual(jpholiday.is_holiday_name(datetime.date(2020, 2, 9)), '特別休暇') self.assertEqual(jpholiday.is_holiday(datetime.date(2020, 2, 10)), False) jpholiday.registry.OriginalHoliday.unregister(TestHoliday)
def get_bank_openday(target_date): """ 指定日から最寄りの銀行営業日を取得 """ # 銀行法施行令により、12/31〜1/3が年末年始の銀行休日となる if datetime.date(target_date.year, 12, 31) <= target_date <= datetime.date( target_date.year + 1, 1, 3): # 前営業日 if target_date.month == 1: date_earlier = datetime.date(target_date.year - 1, 12, 30) else: date_earlier = datetime.date(target_date.year, 12, 30) # 翌営業日 date_later = datetime.date(target_date.year + 1, 1, 4) else: date_earlier = target_date date_later = target_date # 土日祝日の場合は前営業日に飛ばす。 while date_earlier.isoweekday() in ( 6, 7) or jpholiday.is_holiday(date_earlier): date_earlier -= datetime.timedelta(days=1) # 土日祝日の場合は翌営業日に飛ばす。 while date_later.isoweekday() in (6, 7) or jpholiday.is_holiday(date_later): date_later += datetime.timedelta(days=1) return (date_earlier, date_later)
def test_is_holiday(self): """ 型チェック """ with self.assertRaises(JPHolidayTypeError): jpholiday.is_holiday(21210101) with self.assertRaises(JPHolidayTypeError): jpholiday.is_holiday('2021-01-01')
def get_futures_sq_dates(today): sq_dates = [] for year in range(2020, today.year + 2): for month in range(3, 13, 3): sq_date = get_nth_weekday(4, year, month, 1) while True: if not jpholiday.is_holiday(sq_date): break sq_date = get_last_business_date(sq_date) while True: if not jpholiday.is_holiday(sq_date): break sq_date = get_last_business_date(sq_date) sq_dates.append(sq_date) return sq_dates
def run_maker(self, open_data: str, close_data: str) -> str: # 営業しているなら真、営業していないなら偽を返す関数 for c_a in close_data: # 定休日判定 if c_a == self.days[datetime.weekday(self.date)]: return '(定休日)' open_data_d = self.del_bra_maker(open_data) if is_holiday(datetime.now().date()): # 祝日判定 a = open_data_d.find('祝日') if a != -1: return self.overtime_maker(self.run_check(open_data_d, a)) if is_holiday(datetime.now().date() + timedelta(1)): # 祝前日判定 a = open_data_d.find('祝前') if a != -1: return self.overtime_maker(self.run_check(open_data_d, a)) return self.overtime_maker(self.day_check(open_data_d)) # 曜日判定
def to_be_skipped(year, month, day): if not args.skipholiday: return False elif jpholiday.is_holiday(datetime.date(year, month, day)): return True elif (month, day) in custom_holidays: return True
def set_timeTable(self) -> TimeTable: if self.mode == "TakatsukiToKansai": from timetable import TAKATSUKI_TO_KANSAI as diagram distination = "JR高槻駅->関西大学" elif self.mode == "TondaToKansai": from timetable import TONDA_TO_KANSAI as diagram distination = "JR富田駅->関西大学" elif self.mode == "KansaiToTakatsuki": from timetable import KANSAI_TO_TAKATSUKI as diagram distination = "関西大学->JR高槻駅" elif self.mode == "KansaiToTonda": from timetable import KANSAI_TO_TONDA as diagram distination = "関西大学->JR富田駅" else: pass jst_now = datetime.datetime.now(timezone('Asia/Tokyo')) is_holiday = jpholiday.is_holiday(jst_now) if is_holiday or jst_now.weekday() == 6: return TimeTable(distination, diagram.sunday) elif jst_now.weekday() < 5: return TimeTable(distination, diagram.weekday) elif jst_now.weekday() == 5: return TimeTable(distination, diagram.saturday) else: pass
def handle(self, **args): now = datetime.datetime.now() users = CustomUser.objects.all() Schedules.objects.filter(schedule_date__lt=timezone.now()).delete() dat = [] for i in range(6, 7): d = now + datetime.timedelta(days=i) print(d.strftime("%Y-%m-%d")) for u in users: if u.occupation == 1 or jpholiday.is_holiday(d.date()) or d.date().weekday() in (5, 6): dat.append( Schedules(user_id=u.id, schedule_date='{}'.format(d.strftime("%Y-%m-%d")), period=0, status=1) ) dat.append( Schedules(user_id=u.id, schedule_date='{}'.format(d.strftime("%Y-%m-%d")), period=1, status=1) ) dat.append( Schedules(user_id=u.id, schedule_date='{}'.format(d.strftime("%Y-%m-%d")), period=2, status=1) ) Schedules.objects.bulk_create(dat) for user in users: print(user, user.gender, user.id) schedules = Schedules.objects.all() for schedule in schedules: print(schedule, schedule.user_id, schedule.schedule_date, schedule.period, schedule.status)
def main(): try: today = datetime.date(year, month, day) if is_holiday(today): # output logging cloud console write_entry( "It's {} holiday! - scraping-nta-diff-data function".format( is_holiday_name(today))) else: rows = scrape_target_tag() files_num = scrape_files_num(rows) # TODO: get files upload date Checking if the file is already gotten zip_file = download_files(files_num) storage_client = storage.Client() bucket = storage_client.bucket('TARGET_BUCKET') blob = bucket.blob('diff_{}.zip'.format( datetime.now().strftime("%Y%m%d"))) # TODO: confirm target bucket if there is same name file with trying to upload file name blob.upload_from_filename(zip_file) os.remove(zip_file) # TODO: confirm target bucket if there is that updated file whether or not. except Exception as e: return print("Exception: {}. Please contact techDev0".format(e))
def isHoliday(inputDate): array = re.split('/', inputDate) dateCheck = d.date(int(array[0]), int(array[1]), int(array[2])) if dateCheck.weekday() >= 5 or jpholiday.is_holiday(dateCheck): return 1 else: return 0
def chk_now_time(self, sender): print("start check") # 標準では5分後,各自変更を now = datetime.today() + timedelta(minutes=2) print("now + 2min ", now) today = date.today() hour = now.hour minute = now.minute # [0-6],[月-日] #表示するダイヤを決定 if 0 <= hour < 2: # 日付回った場合,前日のダイヤを参照する必要がある hour += 24 #データ形式は0~26時,Time型は0~23で持つため weekday = (now - timedelta(days=1)).weekday() else: weekday = now.weekday() if (jpholiday.is_holiday(today)): weekday = 6 # 祝日の場合,祝日ダイヤにする if weekday == 6: # 休日ダイヤ today_list = hd_list elif weekday == 5: #土曜ダイヤ today_list = sd_list else: # 平日ダイヤ today_list = wd_list #print(today_list) first = chk_train(today_list, hour, minute) print("先発", first) #clear しないと増え続ける #以下冗長な表現,できれば修正するべき #chk_trainの返却値は[00時00分からの経過時間,時,分,行き先,列車種別] self.menu["そのつぎ"].clear() if first is None: self.menu["そのつぎ"].add("なし") self.title = (" ") else: second = chk_train(today_list, first[1], first[2]) print("次発", second) if second is not None: self.menu["そのつぎ"].add( str(second[1]).zfill(2) + ":" + str(second[2]).zfill(2) + " " + str(second[3])) third = chk_train(today_list, second[1], second[2]) print("次々発", third) if third is not None: self.menu["そのつぎ"].add( str(third[1]).zfill(2) + ":" + str(third[2]).zfill(2) + " " + str(third[3])) else: self.menu["そのつぎ"].add("なし") for i in self.menu["そのつぎ"].values(): i.set_callback(hoge) self.title = (str(first[1]).zfill(2) + ":" + str(first[2]).zfill(2) + " " + str(first[3]))
def check_holiday(str_date): date_obj = datetime.datetime.strptime(str_date, '%Y/%m/%d') year = date_obj.year month = date_obj.month day = date_obj.day date = datetime.date(year, month, day) is_holiday = jpholiday.is_holiday(date) return is_holiday
def isBizDay(): Date = datetime.now() # tstr = '2020-04-29 00:00:00' # Date = datetime.strptime(tstr, '%Y-%m-%d %H:%M:%S') if Date.weekday() >= 5 or jpholiday.is_holiday(Date): return False else: return True
def is_biz_day(date): print("### is_biz_day") if date.weekday() >= 5 or jpholiday.is_holiday(date): print("土日祝日") return 0 else: print("平日") return 1
def is_working_day(target: datetime.date) -> bool: """指定日が休日か判定する""" if target.weekday() >= 5: # 土曜 or 日曜 return False if jpholiday.is_holiday(target): # 祝日 return False return True
def holiday(request): if request.method == 'POST': def daterange(date1, date2): for n in range(int((date2 - date1).days) + 1): yield date1 + timedelta(n) holidayFrom = request.POST.get('from') holidayTo = request.POST.get('to') start_date = datetime.strptime(holidayFrom, '%Y/%m/%d').date() end_date = datetime.strptime(holidayTo, '%Y/%m/%d').date() #evens[]リスト作成 evens = [] #(2014,1,1~2018,12,31)の期間でループする for dt in daterange(start_date, end_date): date = dt.strftime("%Y/%m/%d") #日付 if not date == np.nan: hoho = jpholiday.is_holiday(dt) #祝日判定 T or F if not hoho == np.nan: hyo = dt.weekday() # 曜日を取得 if not hyo == np.nan: if hyo == 5 or hyo == 6 or hoho == True: #土日と 祝日に1の値を入れる hois = 1 else: hois = 0 day = date[5:10] #三が日に1 の値を入れる if day == "01/01" or day == "01/02" or day == "01/03": hois = 1 evens.append([date, hoho, hyo, hois, day]) else: hois = hois evens.append([date, hoho, hyo, hois, day]) #evens[]リストをデータフレームに変換 holiday = pd.DataFrame( evens, columns=['date', 'holiday', 'youbi', 'is_holiday', 'day']) holiday = holiday[['date', 'is_holiday']] #sql書き込み cnt = mysql.connector.connect( host='192.168.56.1', # 接続先 port='3306', user='******', # mysqlのuser password='******', # mysqlのpassword database='hems_data_shinyoko', charset='utf8', auth_plugin='mysql_native_password') cnt.cursor() # カーソル取得 cnt.cursor(buffered=True) url = 'mysql://*****:*****@192.168.56.1/hems_data_shinyoko?charset=utf8' sqa.create_engine(url, echo=True) holiday.to_sql('holiday', url, index=None, if_exists='replace') return render(request, 'app/index.html', {})
def holiday_check() -> bool: """ 祝日判定 実行された日が祝日かどうかを判定する。 :return : 祝日判定の結果 """ holiday_jadge = jpholiday.is_holiday(date.today()) return holiday_jadge
def draw_calendar(initial_x, initial_y): delta_x = 45 delta_y = 40 days = [u'日', u'月', u'火', u'水', u'木', u'金', u'土'] x = initial_x y = initial_y for day in days: drawblack.text((x, initial_y), day, font=font24, fill=0) x += delta_x y += delta_y nowtime = datetime.datetime.now() x = initial_x calendar.setfirstweekday(calendar.SUNDAY) for week in calendar.monthcalendar(nowtime.year, nowtime.month): for day in week: if day > 0: drawblack.text((x, y), str(day).rjust(2), font=font24, fill=0) if day == nowtime.day: drawblack.rectangle((x, y + 35, x + 25, y + 37), fill=0) if jpholiday.is_holiday( datetime.date(nowtime.year, nowtime.month, day)): drawblack.arc((x - 4, y, x + 29, y + 37), 0, 360, fill=0) x += delta_x x = initial_x y += delta_y if nowtime.day <= 20: return next_month = (nowtime.month % 12) + 1 for week in calendar.monthcalendar(nowtime.year, next_month): for day in week: if day > 0: drawblack.text((x, y), str(day).rjust(2), font=font24, fill=0) if jpholiday.is_holiday( datetime.date(nowtime.year, next_month, day)): drawblack.arc((x - 4, y, x + 29, y + 37), 0, 360, fill=0) x += delta_x x = initial_x y += delta_y
def first_day_after_holiday(today, holiday_duration): count = 0 for days_to_subtract in range(1, holiday_duration + 1): day = today - timedelta(days=days_to_subtract) if day.weekday() > 4 or jpholiday.is_holiday(day) == True: count += 1 else: return False return True
def kudari(now): holiday = jpholiday.is_holiday(datetime.now().date()) if holiday == True or now.weekday() == 5 or now.weekday() == 6: tr_time2 = kyu_time2 tr_go2 = kyu_go2 else: tr_time2 = hei_time2 tr_go2 = hei_go2 h = int(now.hour) m = 0 day = now.day m_max = tr_time2.shape[1] while True: if np.isnan(tr_time2[h, m]) == True: h = h + 1 m = 0 else: break while True: if h == 24: h = 0 day = day + 1 while True: if np.isnan(tr_time2[h, m]) == True: h = h + 1 m = 0 else: break tr_next2 = datetime(int(now.year), int(now.month), day, h, int(tr_time2[h, m])) if tr_next2 < now: m = m + 1 if m == m_max + 1: h = h + 1 m = 0 if np.isnan(tr_time2[h, m]) == True: h = h + 1 m = 0 else: break tr_lim2 = tr_next2 - now lim_h2, lim_m2, lim_s2 = get_h_m_s(tr_lim2) color = '#fff' w.create_text(yoko * 5 / 8, tate * 3 / 10, text = '次の電車', font = ("", fontsize), tag="X", fill = color) w.create_text(yoko * 6 / 8, tate * 4 / 10, text = tr_go2[h, m], font = ("", fontsize), tag="X", fill = color) w.create_text(yoko * 6 / 8, tate * 5 / 10, text = tr_next2.strftime('%H : %M'), font = ("", int(fontsize*1.2)), tag="X", fill = color) w.create_text(yoko * 7 / 8, tate * 3 / 10, text = '各駅停車', font = ("", fontsize), tag="Y", fill = color) w.create_text(yoko * 3 / 4, tate * 7 / 10, text = lim_h2.zfill(2) + ' : ' + lim_m2.zfill(2) + ' : ' + lim_s2.zfill(2), font = ("", int(fontsize*1.3)), tag="X", fill = color)
def is_holiday(self, date): holidays = [ '01/01', '01/02', '01/03', '08/13', '08/14', '08/15', '12/30', '12/31' ] date_str = '{}/{}'.format(date.strftime('%m'), date.strftime('%d')) if (date_str in holidays): return True else: return (jpholiday.is_holiday(date))
def _isBizDay()->bool: """ 今日が休日かどうか判定する Return: 休日:True 営業日:False """ Date=datetime.datetime.now() if Date.weekday() >= 5 or jpholiday.is_holiday(Date): return True else: return False
def test_datetime_sea_day(self): """ 海の日 """ self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(2020, 7, 23, 1, 1, 1)), '海の日') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(2021, 7, 22, 1, 1, 1)), '海の日') self.assertTrue( jpholiday.is_holiday(datetime.datetime(2020, 7, 23, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(2021, 7, 22, 1, 1, 1))) self.assertEqual( jpholiday.between(datetime.datetime(2020, 7, 23, 1, 1, 1), datetime.datetime(2020, 7, 23, 1, 1, 1)), [(datetime.date(2020, 7, 23), '海の日')]) self.assertEqual( jpholiday.between(datetime.datetime(2021, 7, 22, 1, 1, 1), datetime.datetime(2021, 7, 22, 1, 1, 1)), [(datetime.date(2021, 7, 22), '海の日')])
def test_datetime_mountain_day(self): """ 山の日 """ self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(2020, 8, 10, 1, 1, 1)), '山の日') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(2021, 8, 8, 1, 1, 1)), '山の日') self.assertTrue( jpholiday.is_holiday(datetime.datetime(2020, 8, 10, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(2021, 8, 8, 1, 1, 1))) self.assertEqual( jpholiday.between(datetime.datetime(2020, 8, 10, 1, 1, 1), datetime.datetime(2020, 8, 10, 1, 1, 1)), [(datetime.date(2020, 8, 10), '山の日')]) self.assertEqual( jpholiday.between(datetime.datetime(2021, 8, 8, 1, 1, 1), datetime.datetime(2021, 8, 8, 1, 1, 1)), [(datetime.date(2021, 8, 8), '山の日')])
def writeSchedule(sheet): day = nextMonth().date() rowNum = 2 # 曜日と列番号の辞書 dic = {0 : 6 , 1 : 11 , 2 : 16 , 3 : 21 , 4 : 26 , 5 : 31 , 6 : 36} for i in range(calendar.monthrange(day.year, day.month)[1]): # 曜日に応じた列番号を取得 colNum = dic[day.weekday()] # 日付の記入 sheet.cell(row = rowNum, column = colNum).value = day # 第3SUNDAYの場合 if (colNum == 36 and rowNum == 42): input3rdSunday(sheet) # 祝日の場合 elif jpholiday.is_holiday(day): # 曜日を祝日にする sheet.cell(row = rowNum + 1, column = colNum).value = '祝' # 日付と曜日欄の文字色を赤に sheet.cell(row = rowNum , column = colNum).font = Font(color=colors.RED) sheet.cell(row = rowNum + 1, column = colNum).font = Font(color=colors.RED) # TODO 一律、日曜出勤メンバーを出す RangeCopyCell(sheet, 36, 104, 36 + 4, 104 + 15, colNum - 36, -(104 - 2 - rowNum)) # それ以外 else: # シフトのコピー RangeCopyCell(sheet, colNum, 104, colNum + 4, 104 + 15, 0, -(104 - 2 - rowNum)) # 日付を1日足す day += relativedelta(days = 1) # 月曜日の場合 if day.weekday() == 0: # TODO 次の行へ移動する rowNum += 20
def test_datetime_other_holiday(self): """ 皇室慶弔行事に伴う祝日 """ self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(1959, 4, 10, 1, 1, 1)), '皇太子・明仁親王の結婚の儀') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(1989, 2, 24, 1, 1, 1)), '昭和天皇の大喪の礼') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(1990, 11, 12, 1, 1, 1)), '即位の礼正殿の儀') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(1993, 6, 9, 1, 1, 1)), '皇太子・皇太子徳仁親王の結婚の儀') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(2019, 5, 1, 1, 1, 1)), '天皇の即位の日') self.assertEqual( jpholiday.is_holiday_name(datetime.datetime(2019, 10, 22, 1, 1, 1)), '即位礼正殿の儀') self.assertTrue( jpholiday.is_holiday(datetime.datetime(1959, 4, 10, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(1989, 2, 24, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(1990, 11, 12, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(1993, 6, 9, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(2019, 5, 1, 1, 1, 1))) self.assertTrue( jpholiday.is_holiday(datetime.datetime(2019, 10, 22, 1, 1, 1))) self.assertEqual( jpholiday.between(datetime.datetime(1959, 4, 10, 1, 1, 1), datetime.datetime(1959, 4, 10, 1, 1, 1)), [(datetime.date(1959, 4, 10), '皇太子・明仁親王の結婚の儀')]) self.assertEqual( jpholiday.between(datetime.datetime(1989, 2, 24, 1, 1, 1), datetime.datetime(1989, 2, 24, 1, 1, 1)), [(datetime.date(1989, 2, 24), '昭和天皇の大喪の礼')]) self.assertEqual( jpholiday.between(datetime.datetime(1990, 11, 12, 1, 1, 1), datetime.datetime(1990, 11, 12, 1, 1, 1)), [(datetime.date(1990, 11, 12), '即位の礼正殿の儀')]) self.assertEqual( jpholiday.between(datetime.datetime(1993, 6, 9, 1, 1, 1), datetime.datetime(1993, 6, 9, 1, 1, 1)), [(datetime.date(1993, 6, 9), '皇太子・皇太子徳仁親王の結婚の儀')]) self.assertEqual( jpholiday.between(datetime.datetime(2019, 5, 1, 1, 1, 1), datetime.datetime(2019, 5, 1, 1, 1, 1)), [(datetime.date(2019, 5, 1), '天皇の即位の日')]) self.assertEqual( jpholiday.between(datetime.datetime(2019, 10, 22, 1, 1, 1), datetime.datetime(2019, 10, 22, 1, 1, 1)), [(datetime.date(2019, 10, 22), '即位礼正殿の儀')])
def run(self): ddf_calendar = dd.read_csv(self.calendar_csv_filename) print(ddf_calendar.npartitions) use_columns_in_calendar = [ 'listing_id', 'date', 'price', ] print(ddf_calendar.head()) ddf_calendar = ddf_calendar.loc[:, use_columns_in_calendar] ddf_calendar = ddf_calendar.dropna() print(ddf_calendar.head()) # price ddf_calendar['price_amount'] = ddf_calendar['price'].map( lambda x: int(float(str(x).replace(',', '').replace('$', ''))), meta=('x', int)) # need to specify type # date ddf_calendar['datetime'] = ddf_calendar['date'].map( lambda x: datetime.datetime.strptime(str(x), '%Y-%m-%d'), meta=('x', object)) # need to specify type ddf_calendar['month'] = ddf_calendar['datetime'].map( lambda x: x.month, meta=('x', int)) # need to specify type ddf_calendar['day'] = ddf_calendar['datetime'].map( lambda x: x.day, meta=('x', int)) # need to specify type ddf_calendar['day_of_week'] = ddf_calendar['datetime'].map( lambda x: x.weekday(), meta=('x', int)) # need to specify type ddf_calendar['holiday'] = ddf_calendar['datetime'].map( lambda x: 1 if jpholiday.is_holiday(x.date()) else 0, meta=('x', int)) # need to specify type ddf_calendar = ddf_calendar.categorize( columns=['month', 'day_of_week', 'day']) # need to categorize ddf_calendar = dd.get_dummies(ddf_calendar, columns=['month', 'day_of_week', 'day']) del ddf_calendar['date'] del ddf_calendar['price'] del ddf_calendar['datetime'] # ddf_calendar = ddf_calendar.reset_index() # ddf_calendar = ddf_calendar.rename(columns={'id': 'listing_id'}) ddf_calendar = ddf_calendar.compute() print(ddf_calendar.shape) print(ddf_calendar.head()) with open(self.output().path, "w") as target: ddf_calendar.to_csv(target)
def _is_jpx_holiday(d: datetime) -> bool: if jpholiday.is_holiday(d.date()): return True if d.month == 12 and d.day == 31: return True if d.month == 1 and (d.day == 1 or d.day == 2 or d.day == 3): return True if d.weekday() >= 5: # Skip Saturday and Sunday return True return False
def _is_holiday(dt: date) -> bool: """休日であるかどうかを返します。 Arguments: dt {date} -- 対象の日付 Returns: bool -- 土日祝のいずれかに当てはまる場合はTrueを返します。 """ if dt.weekday() in [WEEKDAYS["土"], WEEKDAYS["日"]]: return True elif jpholiday.is_holiday(dt): return True else: return False