-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsts.go
84 lines (73 loc) · 1.51 KB
/
consts.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
package chrono
import "fmt"
// Weekday specifies the day of the week (Monday = 0, ...).
// Not compatible standard library's time.Weekday (in which Sunday = 0, ...).
type Weekday int
// The days of the week.
const (
Monday Weekday = iota + 1
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
)
func (d Weekday) String() string {
return longWeekdayName(int(d))
}
func longWeekdayName(d int) string {
if d < int(Monday) || d > int(Sunday) {
return fmt.Sprintf("%%!Weekday(%d)", d)
}
return longDayNames[d-1]
}
var longDayNames = [7]string{
Monday - 1: "Monday",
Tuesday - 1: "Tuesday",
Wednesday - 1: "Wednesday",
Thursday - 1: "Thursday",
Friday - 1: "Friday",
Saturday - 1: "Saturday",
Sunday - 1: "Sunday",
}
// Month specifies the month of the year (January = 1, ...).
type Month int
// The months of the year.
const (
January Month = iota + 1
February
March
April
May
June
July
August
September
October
November
December
)
func (m Month) String() string {
return longMonthName(int(m))
}
func longMonthName(m int) string {
if m < int(January) || m > int(December) {
return fmt.Sprintf("%%!Month(%d)", m)
}
return longMonthNames[m-1]
}
var longMonthNames = [12]string{
January - 1: "January",
February - 1: "February",
March - 1: "March",
April - 1: "April",
May - 1: "May",
June - 1: "June",
July - 1: "July",
August - 1: "August",
September - 1: "September",
October - 1: "October",
November - 1: "November",
December - 1: "December",
}