-
Notifications
You must be signed in to change notification settings - Fork 0
/
brazil.jl
71 lines (57 loc) · 1.43 KB
/
brazil.jl
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
"""
BrazilCalendar
Brazilian calendar.
"""
abstract type BrazilCalendar <: WesternCalendar end
"""
BrazilSettlement
Calendar including public holidays.
"""
struct BrazilSettlement <: BrazilCalendar end
"""
BrazilExchange
Holidays for the Bovespa stock exchange.
"""
struct BrazilExchange <: BrazilCalendar end
function isbusinessday(date::Date, calendar::BrazilSettlement)
y, m, d = yearmonthday(date)
w = dayofweek(date)
dd = dayofyear(date)
em = eastermonday(y, calendar)
if (
isweekend(w)
# New Year's Day
|| (m, d) == (January, 1)
# Tiradentes Day
|| (m, d) == (April, 21)
# Labor Day
|| (m, d) == (May, 1)
# Independence Day
|| (m, d) == (September, 7)
# Nossa Sra. Aparecida Day
|| (m, d) == (October, 12)
# All Souls Day
|| (m, d) == (November, 2)
# Republic Day
|| (m, d) == (November, 15)
# Christmas
|| (m, d) == (December, 25)
# Passion of Christ
|| (dd == em - 3)
# Carnival
|| (dd == em - 49 || dd == em - 48)
# Corpus Christi
|| (dd == em + 59)
)
return false
end
return true
end
function isbusinessday(date::Date, calendar::BrazilExchange)
y, m, d = yearmonthday(date)
w = dayofweek(date)
dd = dayofyear(date)
em = eastermonday(y, calendar)
# TODO: do it
return nothing
end