-
Notifications
You must be signed in to change notification settings - Fork 0
/
HolidayUtility_Linux.py
87 lines (79 loc) · 3.38 KB
/
HolidayUtility_Linux.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -*- coding:shift-jis -*-
import sys
#sys.path.append('../x64/Debug/')
#sys.path.append('../PythonUtility/')
import datetime as dt
import pandas as pd
import numpy as np
#import pyodbc
import IoUtility as iou
#import holidays
# import文を関数内で定義すると、multi-thread 呼び出しの際にうまくいかない場合がある。 2017.11.08
import workalendar as wk
from workalendar import europe, america, usa, canada, oceania, asia, africa
# http://stackoverflow.com/questions/1029794/holiday-files-for-g20-countries
def is_a_workday(_nation, _date):
cal_dict = {
# = Europe =
'Belgium':wk.europe.Belgium(),
'Czech':wk.europe.CzechRepublic(),
'Denmark':wk.europe.Denmark(),
'Estonia':wk.europe.Estonia(),
'European Central Bank':wk.europe.EuropeanCentralBank(),
'Finland':wk.europe.Finland(),
'France':wk.europe.France(),
#'France (Alsace / Moselle)':wk.europe.France(),
'Germany':wk.europe.Germany(),
'Greece':wk.europe.Greece(),
'Hungary':wk.europe.Hungary(),
'Iceland':wk.europe.Iceland(),
'Italy':wk.europe.Italy(),
'Luxembourg':wk.europe.Luxembourg(),
'Netherlands':wk.europe.Netherlands(),
'Norway':wk.europe.Norway(),
'Poland':wk.europe.Poland(),
'Portugal':wk.europe.Portugal(),
'Slovakia':wk.europe.Slovakia(),
'Sweden':wk.europe.Sweden(),
'United Kingdom':wk.europe.UnitedKingdom(),
'UK':wk.europe.UnitedKingdom(),
'U.K.':wk.europe.UnitedKingdom(),
'Spain':wk.europe.Spain(),
'Slovenia':wk.europe.Slovenia(),
'Switzerland':wk.europe.Switzerland(),
# = America =
'Brazil':wk.america.Brazil(),
'Chile':wk.america.Chile(),
'Colombia':wk.america.Colombia(),
'Mexico':wk.america.Mexico(),
'Panama':wk.america.Panama(),
'United States':wk.usa.UnitedStates(),
'Canada':wk.canada.Canada(),
# = Asia =
'Japan':wk.asia.Japan(),
'Qatar':wk.asia.Qatar(),
'South Korea':wk.asia.SouthKorea(),
'Taiwan':wk.asia.Taiwan(),
#'China':wk.asia.China(),
# = Oceania =
'Australia':wk.oceania.Australia(),
'Marshall Islands':wk.oceania.MarshallIslands(),
# = Africa =
'Algeria':wk.africa.Algeria(),
'Benin':wk.africa.Benin(),
'Ivory Coast':wk.africa.IvoryCoast(),
'Madagascar':wk.africa.Madagascar(),
#'Sテ」o Tomテゥ':wk.africa.SaoTome(),
'South Africa':wk.africa.SouthAfrica(),
}
cal = cal_dict[_nation] #wk.europe.France()
#fr_holidays = cal.holidays(2013)
#print(fr_holidays)
#print('')
#print(cal.is_working_day(dt.date(2013,12,29)))
return cal.is_working_day(_date)
def is_a_holiday(_nation, _date):
return not is_a_workday(_nation, _date)
if __name__ == '__main__':
x = is_a_holiday('Japan',dt.date(2016,8,28))
print(x)