-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathen_US.go
182 lines (145 loc) · 3.75 KB
/
en_US.go
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package kal
// locale: en_US
// NOTE: Work in progress!
// Anything that's specific to the US, with the exception of some movable dates which are in movable.go
// This calendar has a corresponding locale code in the NewCalendar function in calendar.go
import (
"time"
)
type USCalendar struct{}
// Create a new US calendar
func NewUSCalendar() USCalendar {
return USCalendar{}
}
// Finds the US name for a day of the week.
// Note that time.Weekday starts at 0 with Sunday, not Monday.
func (nc USCalendar) DayName(day time.Weekday) string {
return day.String()
}
// Finds the US name for a given month
func (nc USCalendar) MonthName(month time.Month) string {
return month.String()
}
// Checks if a given date is a "red day" (public holiday) in the US calendar.
// Returns true/false, a description and true/false for if it's a flag day.
// The dates will never overlap.
func (nc USCalendar) RedDay(date time.Time) (bool, string, bool) {
// Source: http://en.wikipedia.org/wiki/Public_holidays_in_the_United_States
// Source: http://timpanogos.wordpress.com/flag-fly-dates/
var (
desc string
flag bool
)
// Sundays
if date.Weekday() == time.Sunday {
desc = "Sunday"
}
// Election Day
if atElectionDay(date) {
desc = "Election Day"
flag = false
}
// New Year's Day
if atMD(date, 1, 1) {
desc = "New Year's Day"
flag = true
}
// Birthday of Dr. Martin Luther King, Jr.
if atNthWeekdayOfMonth(date, 3, time.Monday, time.January) {
desc = "Martin Luther King Day"
flag = true
}
// Inauguration Day
if atInaugurationDay(date) {
desc = "Inauguration Day"
flag = true
}
// Lincoln's birthday
if atMD(date, 2, 12) {
desc = "Lincoln's birthday"
flag = true
}
// Washington's Birthday / Presidents' Day
if atNthWeekdayOfMonth(date, 3, time.Monday, time.February) {
desc = "Presidents' Day"
flag = true
}
// Armed Forces Day
if atNthWeekdayOfMonth(date, 3, time.Saturday, time.May) {
desc = "Armed Forces Day"
flag = true
}
// Memorial Day
if atLastWeekday(date, time.Monday, time.May) {
desc = "Memorial Day"
flag = true
}
// 4th of July
if atMD(date, 7, 4) {
desc = "Independence Day"
flag = true
}
// Labor Day
if atNthWeekdayOfMonth(date, 1, time.Monday, time.September) {
desc = "Labor Day"
flag = true
}
// Columbus Day
if atNthWeekdayOfMonth(date, 2, time.Monday, time.October) {
desc = "Columbus Day"
flag = true
}
// Veterans Day
if atMD(date, 11, 11) {
desc = "Veterans Day"
flag = true
}
// Thanksgiving Day
if atNthWeekdayOfMonth(date, 4, time.Thursday, time.November) {
desc = "Thanksgiving Day"
flag = true
}
// Christmas
if atMD(date, 12, 25) {
desc = "Christmas Day"
flag = true
}
// Red days
if desc != "" {
// Then return
return true, desc, flag
}
// Normal days
return false, desc, false
}
// Some days are not red, but special in one way or another.
// Checks if a given date is notable. Returns true/false if the
// given date is notable, a comma separated description (in case there are more
// than one notable event that day) and true/false depending on if it's a flag
// flying day or not.
func (nc USCalendar) NotableDay(date time.Time) (bool, string, bool) {
var (
//descriptions []string
//flag bool
)
// Since days may overlap, flag flying days must come first.
// --- Flag flying days ---
// --- Other days ---
// No notable events
return false, "", false
}
// Checks if a given date is in a notable time range (summer holidays, for instance)
func (nc USCalendar) NotablePeriod(date time.Time) (bool, string) {
// TODO:
// Christmas time
// summer/winter/spring/autumn time
// etc
return false, ""
}
func (nc USCalendar) MondayFirst() bool {
return false
}
// An ordinary day
func (nc USCalendar) NormalDay() string {
return "Ordinary"
}