-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtr_TR.go
151 lines (119 loc) · 3.43 KB
/
tr_TR.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
package kal
// locale: tr_TR
// NOTE: Work in progress!
// This calendar has a corresponding locale code in the NewCalendar function in calendar.go
import (
"time"
)
type TRCalendar struct{}
// Create a new US calendar
func NewTRCalendar() TRCalendar {
return TRCalendar{}
}
// Finds the TR name for a day of the week.
// Note that time.Weekday starts at 0 with Sunday, not Monday.
func (tc TRCalendar) DayName(day time.Weekday) string {
return []string{"pazar", "pazartesi", "salı", "çarşamba", "perşembe", "cuma", "cumartesi"}[int(day)]
}
// Finds the english name for a day of the week.
// Note that time.Weekday starts at 0 with Sunday, not Monday.
func (tc TRCalendar) DayNameInEnglish(day time.Weekday) string {
return day.String()
}
// Finds the TR name for a given month
func (tc TRCalendar) MonthName(month time.Month) string {
return []string{"ocak", "şubat", "mart", "nisan", "mayıs", "haziran", "temmuz", "ağustos", "eylül", "ekim", "kasım", "aralık"}[int(month)-1]
}
// Finds the english name for a given month
func (tc TRCalendar) MonthNameInEnglish(month time.Month) string {
return month.String()
}
// Checks if a given date is a "red day" (public holiday) in the TR calendar.
// Returns true/false, a description and true/false for if it's a flag day.
func (tc TRCalendar) RedDay(date time.Time) (bool, string, bool) {
// Source: https://en.wikipedia.org/wiki/Public_holidays_in_Turkey
var (
desc string
flag bool
)
// Sundays
if date.Weekday() == time.Sunday {
desc = "Pazar"
}
// New Year's Day
if atMD(date, 1, 1) {
desc = "Yılbaşı"
flag = true
}
// National sovereignty and children's day
if atMD(date, 4, 23) {
desc = "Ulusal Egemenlik ve Çocuk Bayramı"
flag = true
}
// Labor and Solidarity Day
if atMD(date, 5, 1) {
desc = "İşçi Bayramı"
flag = true
}
// Commemoration of Atatürk, Youth and Sports Day
if atMD(date, 5, 19) {
desc = "Atatürk'ü Anma, Gençlik ve Spor Bayramı"
flag = true
}
// Democracy and National Unity Day
if atMD(date, 7, 15) {
desc = "Demokrasi ve Milli Birlik Günü"
flag = true
}
// Victory Day
if atMD(date, 8, 30) {
desc = "Zafer Bayramı"
flag = true
}
// Republic Day
if atMD(date, 10, 29) {
desc = "Cumhuriyet Bayramı"
flag = true
}
/**
* TODO: calculation for Ramadan Feast and Sacrifice Day will be added.
*/
// 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 (tc TRCalendar) NotableDay(date time.Time) (bool, string, bool) {
var (
//descriptions []string
//flag bool
)
// Since days may overlap, "flaggdager" must come first for the flag
// flying days to be correct.
// --- Flag days ---
// --- Non-flag days ---
// No notable events
return false, "", false
}
// Checks if a given date is in a notable time range (summer holidays, for instance)
func (tc TRCalendar) NotablePeriod(date time.Time) (bool, string) {
// TODO:
// summer/winter/spring/autumn time
// etc
return false, ""
}
func (tc TRCalendar) MondayFirst() bool {
return true
}
// An ordinary day
func (tc TRCalendar) NormalDay() string {
return "Sıradan"
}