OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / go-playground / locales / hy / hy.go
1 package hy
2
3 import (
4         "math"
5         "strconv"
6         "time"
7
8         "github.com/go-playground/locales"
9         "github.com/go-playground/locales/currency"
10 )
11
12 type hy struct {
13         locale                 string
14         pluralsCardinal        []locales.PluralRule
15         pluralsOrdinal         []locales.PluralRule
16         pluralsRange           []locales.PluralRule
17         decimal                string
18         group                  string
19         minus                  string
20         percent                string
21         perMille               string
22         timeSeparator          string
23         inifinity              string
24         currencies             []string // idx = enum of currency code
25         currencyPositivePrefix string
26         currencyNegativePrefix string
27         monthsAbbreviated      []string
28         monthsNarrow           []string
29         monthsWide             []string
30         daysAbbreviated        []string
31         daysNarrow             []string
32         daysShort              []string
33         daysWide               []string
34         periodsAbbreviated     []string
35         periodsNarrow          []string
36         periodsShort           []string
37         periodsWide            []string
38         erasAbbreviated        []string
39         erasNarrow             []string
40         erasWide               []string
41         timezones              map[string]string
42 }
43
44 // New returns a new instance of translator for the 'hy' locale
45 func New() locales.Translator {
46         return &hy{
47                 locale:                 "hy",
48                 pluralsCardinal:        []locales.PluralRule{2, 6},
49                 pluralsOrdinal:         []locales.PluralRule{2, 6},
50                 pluralsRange:           []locales.PluralRule{2, 6},
51                 decimal:                ",",
52                 group:                  " ",
53                 minus:                  "-",
54                 percent:                "%",
55                 perMille:               "‰",
56                 timeSeparator:          ":",
57                 inifinity:              "∞",
58                 currencies:             []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "֏", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "A$", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNX", "CN¥", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59                 currencyPositivePrefix: " ",
60                 currencyNegativePrefix: " ",
61                 monthsAbbreviated:      []string{"", "հնվ", "փտվ", "մրտ", "ապր", "մյս", "հնս", "հլս", "օգս", "սեպ", "հոկ", "նոյ", "դեկ"},
62                 monthsNarrow:           []string{"", "Հ", "Փ", "Մ", "Ա", "Մ", "Հ", "Հ", "Օ", "Ս", "Հ", "Ն", "Դ"},
63                 monthsWide:             []string{"", "հունվարի", "փետրվարի", "մարտի", "ապրիլի", "մայիսի", "հունիսի", "հուլիսի", "օգոստոսի", "սեպտեմբերի", "հոկտեմբերի", "նոյեմբերի", "դեկտեմբերի"},
64                 daysAbbreviated:        []string{"կիր", "երկ", "երք", "չրք", "հնգ", "ուր", "շբթ"},
65                 daysNarrow:             []string{"Կ", "Ե", "Ե", "Չ", "Հ", "Ո", "Շ"},
66                 daysShort:              []string{"կր", "եկ", "եք", "չք", "հգ", "ու", "շբ"},
67                 daysWide:               []string{"կիրակի", "երկուշաբթի", "երեքշաբթի", "չորեքշաբթի", "հինգշաբթի", "ուրբաթ", "շաբաթ"},
68                 periodsAbbreviated:     []string{"ԿԱ", "ԿՀ"},
69                 periodsNarrow:          []string{"ա", "հ"},
70                 periodsWide:            []string{"AM", "PM"},
71                 erasAbbreviated:        []string{"", ""},
72                 erasNarrow:             []string{"", ""},
73                 erasWide:               []string{"Քրիստոսից առաջ", "Քրիստոսից հետո"},
74                 timezones:              map[string]string{"NZDT": "Նոր Զելանդիայի ամառային ժամանակ", "ART": "Արգենտինայի ստնադարտ ժամանակ", "AST": "Ատլանտյան ստանդարտ ժամանակ", "HNEG": "Արևելյան Գրենլանդիայի ստանդարտ ժամանակ", "HEEG": "Արևելյան Գրենլանդիայի ամառային ժամանակ", "GYT": "Գայանայի ժամանակ", "WEZ": "Արևմտյան Եվրոպայի ստանդարտ ժամանակ", "ACDT": "Կենտրոնական Ավստրալիայի ամառային ժամանակ", "WIB": "Արևմտյան Ինդոնեզիայի ժամանակ", "PST": "Խաղաղօվկիանոսյան ստանդարտ ժամանակ", "MESZ": "Կենտրոնական Եվրոպայի ամառային ժամանակ", "ADT": "Ատլանտյան ամառային ժամանակ", "EDT": "Արևելյան Ամերիկայի ամառային ժամանակ", "ACST": "Կենտրոնական Ավստրալիայի ստանդարտ ժամանակ", "HEPMX": "Մեքսիկայի խաղաղօվկիանոսյան ամառային ժամանակ", "HNPMX": "Մեքսիկայի խաղաղօվկիանոսյան ստանդարտ ժամանակ", "JST": "Ճապոնիայի ստանդարտ ժամանակ", "JDT": "Ճապոնիայի ամառային ժամանակ", "OEZ": "Արևելյան Եվրոպայի ստանդարտ ժամանակ", "LHDT": "Լորդ Հաուի ամառային ժամանակ", "HNOG": "Արևմտյան Գրենլանդիայի ստանդարտ ժամանակ", "EST": "Արևելյան Ամերիկայի ստանդարտ ժամանակ", "CAT": "Կենտրոնական Աֆրիկայի ժամանակ", "WAST": "Արևմտյան Աֆրիկայի ամառային ժամանակ", "GFT": "Ֆրանսիական Գվիանայի ժամանակ", "CHAST": "Չաթեմ կղզու ստանդարտ ժամանակ", "AEDT": "Արևելյան Ավստրալիայի ամառային ժամանակ", "HNNOMX": "Հյուսիսարևմտյան Մեքսիկայի ստանդարտ ժամանակ", "WITA": "Կենտրոնական Ինդոնեզիայի ժամանակ", "EAT": "Արևելյան Աֆրիկայի ժամանակ", "HNT": "Նյուֆաունդլենդի ստանդարտ ժամանակ", "HEPM": "Սեն Պիեռ և Միքելոնի ամառային ժամանակ", "MDT": "MDT", "GMT": "Գրինվիչի ժամանակ", "AWDT": "Արևմտյան Ավստրալիայի ամառային ժամանակ", "CST": "Կենտրոնական Ամերիկայի ստանդարտ ժամանակ", "UYST": "Ուրուգվայի ամառային ժամանակ", "ACWST": "Կենտրոնական Ավստրալիայի արևմտյան ստանդարտ ժամանակ", "ARST": "Արգենտինայի ամառային ժամանակ", "ECT": "Էկվադորի ժամանակ", "∅∅∅": "Ամազոնյան ամառային ժամանակ", "COST": "Կոլումբիայի ամառային ժամանակ", "SAST": "Հարավային Աֆրիկայի ժամանակ", "CLST": "Չիլիի ամառային ժամանակ", "MST": "MST", "VET": "Վենեսուելայի ժամանակ", "TMST": "Թուրքմենստանի ամառային ժամանակ", "MEZ": "Կենտրոնական Եվրոպայի ստանդարտ ժամանակ", "ACWDT": "Կենտրոնական Ավստրալիայի արևմտյան ամառային ժամանակ", "MYT": "Մալայզիայի ժամանակ", "HAST": "Հավայան-ալեության ստանդարտ ժամանակ", "WART": "Արևմտյան Արգենտինայի ստնադարտ ժամանակ", "IST": "Հնդկաստանի ստանդարտ ժամանակ", "CLT": "Չիլիի ստանդարտ ժամանակ", "HNPM": "Սեն Պիեռ և Միքելոնի ստանդարտ ժամանակ", "CHADT": "Չաթեմ կղզու ամառային ժամանակ", "SRT": "Սուրինամի ժամանակ", "CDT": "Կենտրոնական Ամերիկայի ամառային ժամանակ", "TMT": "Թուրքմենստանի ստանդարտ ժամանակ", "HECU": "Կուբայի ամառային ժամանակ", "BT": "Բութանի ժամանակ", "AWST": "Արևմտյան Ավստրալիայի ստանդարտ ժամանակ", "HENOMX": "Հյուսիսարևմտյան Մեքսիկայի ամառային ժամանակ", "OESZ": "Արևելյան Եվրոպայի ամառային ժամանակ", "AEST": "Արևելյան Ավստրալիայի ստանդարտ ժամանակ", "WAT": "Արևմտյան Աֆրիկայի ստանդարտ ժամանակ", "HAT": "Նյուֆաունդլենդի ամառային ժամանակ", "AKST": "Ալյասկայի ստանդարտ ժամանակ", "BOT": "Բոլիվիայի ժամանակ", "HKST": "Հոնկոնգի ամառային ժամանակ", "WIT": "Արևելյան Ինդոնեզիայի ժամանակ", "HKT": "Հոնկոնգի ստանդարտ ժամանակ", "WESZ": "Արևմտյան Եվրոպայի ամառային ժամանակ", "ChST": "Չամոռոյի ժամանակ", "PDT": "Խաղաղօվկիանոսյան ամառային ժամանակ", "NZST": "Նոր Զելանդիայի ստանդարտ ժամանակ", "WARST": "Արևմտյան Արգենտինայի ամառային ժամանակ", "HEOG": "Արևմտյան Գրենլանդիայի ամառային ժամանակ", "SGT": "Սինգապուրի ժամանակ", "HNCU": "Կուբայի ստանդարտ ժամանակ", "HADT": "Հավայան-ալեության ամառային ժամանակ", "LHST": "Լորդ Հաուի ստանդարտ ժամանակ", "COT": "Կոլումբիայի ստանդարտ ժամանակ", "AKDT": "Ալյասկայի ամառային ժամանակ", "UYT": "Ուրուգվայի ստանդարտ ժամանակ"},
75         }
76 }
77
78 // Locale returns the current translators string locale
79 func (hy *hy) Locale() string {
80         return hy.locale
81 }
82
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'hy'
84 func (hy *hy) PluralsCardinal() []locales.PluralRule {
85         return hy.pluralsCardinal
86 }
87
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'hy'
89 func (hy *hy) PluralsOrdinal() []locales.PluralRule {
90         return hy.pluralsOrdinal
91 }
92
93 // PluralsRange returns the list of range plural rules associated with 'hy'
94 func (hy *hy) PluralsRange() []locales.PluralRule {
95         return hy.pluralsRange
96 }
97
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hy'
99 func (hy *hy) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101         n := math.Abs(num)
102         i := int64(n)
103
104         if i == 0 || i == 1 {
105                 return locales.PluralRuleOne
106         }
107
108         return locales.PluralRuleOther
109 }
110
111 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hy'
112 func (hy *hy) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
113
114         n := math.Abs(num)
115
116         if n == 1 {
117                 return locales.PluralRuleOne
118         }
119
120         return locales.PluralRuleOther
121 }
122
123 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hy'
124 func (hy *hy) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
125
126         start := hy.CardinalPluralRule(num1, v1)
127         end := hy.CardinalPluralRule(num2, v2)
128
129         if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
130                 return locales.PluralRuleOne
131         } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
132                 return locales.PluralRuleOther
133         }
134
135         return locales.PluralRuleOther
136
137 }
138
139 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
140 func (hy *hy) MonthAbbreviated(month time.Month) string {
141         return hy.monthsAbbreviated[month]
142 }
143
144 // MonthsAbbreviated returns the locales abbreviated months
145 func (hy *hy) MonthsAbbreviated() []string {
146         return hy.monthsAbbreviated[1:]
147 }
148
149 // MonthNarrow returns the locales narrow month given the 'month' provided
150 func (hy *hy) MonthNarrow(month time.Month) string {
151         return hy.monthsNarrow[month]
152 }
153
154 // MonthsNarrow returns the locales narrow months
155 func (hy *hy) MonthsNarrow() []string {
156         return hy.monthsNarrow[1:]
157 }
158
159 // MonthWide returns the locales wide month given the 'month' provided
160 func (hy *hy) MonthWide(month time.Month) string {
161         return hy.monthsWide[month]
162 }
163
164 // MonthsWide returns the locales wide months
165 func (hy *hy) MonthsWide() []string {
166         return hy.monthsWide[1:]
167 }
168
169 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
170 func (hy *hy) WeekdayAbbreviated(weekday time.Weekday) string {
171         return hy.daysAbbreviated[weekday]
172 }
173
174 // WeekdaysAbbreviated returns the locales abbreviated weekdays
175 func (hy *hy) WeekdaysAbbreviated() []string {
176         return hy.daysAbbreviated
177 }
178
179 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
180 func (hy *hy) WeekdayNarrow(weekday time.Weekday) string {
181         return hy.daysNarrow[weekday]
182 }
183
184 // WeekdaysNarrow returns the locales narrow weekdays
185 func (hy *hy) WeekdaysNarrow() []string {
186         return hy.daysNarrow
187 }
188
189 // WeekdayShort returns the locales short weekday given the 'weekday' provided
190 func (hy *hy) WeekdayShort(weekday time.Weekday) string {
191         return hy.daysShort[weekday]
192 }
193
194 // WeekdaysShort returns the locales short weekdays
195 func (hy *hy) WeekdaysShort() []string {
196         return hy.daysShort
197 }
198
199 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
200 func (hy *hy) WeekdayWide(weekday time.Weekday) string {
201         return hy.daysWide[weekday]
202 }
203
204 // WeekdaysWide returns the locales wide weekdays
205 func (hy *hy) WeekdaysWide() []string {
206         return hy.daysWide
207 }
208
209 // Decimal returns the decimal point of number
210 func (hy *hy) Decimal() string {
211         return hy.decimal
212 }
213
214 // Group returns the group of number
215 func (hy *hy) Group() string {
216         return hy.group
217 }
218
219 // Group returns the minus sign of number
220 func (hy *hy) Minus() string {
221         return hy.minus
222 }
223
224 // FmtNumber returns 'num' with digits/precision of 'v' for 'hy' and handles both Whole and Real numbers based on 'v'
225 func (hy *hy) FmtNumber(num float64, v uint64) string {
226
227         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
228         l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
229         count := 0
230         inWhole := v == 0
231         b := make([]byte, 0, l)
232
233         for i := len(s) - 1; i >= 0; i-- {
234
235                 if s[i] == '.' {
236                         b = append(b, hy.decimal[0])
237                         inWhole = true
238                         continue
239                 }
240
241                 if inWhole {
242                         if count == 3 {
243                                 for j := len(hy.group) - 1; j >= 0; j-- {
244                                         b = append(b, hy.group[j])
245                                 }
246                                 count = 1
247                         } else {
248                                 count++
249                         }
250                 }
251
252                 b = append(b, s[i])
253         }
254
255         if num < 0 {
256                 b = append(b, hy.minus[0])
257         }
258
259         // reverse
260         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
261                 b[i], b[j] = b[j], b[i]
262         }
263
264         return string(b)
265 }
266
267 // FmtPercent returns 'num' with digits/precision of 'v' for 'hy' and handles both Whole and Real numbers based on 'v'
268 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
269 func (hy *hy) FmtPercent(num float64, v uint64) string {
270         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
271         l := len(s) + 3
272         b := make([]byte, 0, l)
273
274         for i := len(s) - 1; i >= 0; i-- {
275
276                 if s[i] == '.' {
277                         b = append(b, hy.decimal[0])
278                         continue
279                 }
280
281                 b = append(b, s[i])
282         }
283
284         if num < 0 {
285                 b = append(b, hy.minus[0])
286         }
287
288         // reverse
289         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
290                 b[i], b[j] = b[j], b[i]
291         }
292
293         b = append(b, hy.percent...)
294
295         return string(b)
296 }
297
298 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hy'
299 func (hy *hy) FmtCurrency(num float64, v uint64, currency currency.Type) string {
300
301         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
302         symbol := hy.currencies[currency]
303         l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
304         count := 0
305         inWhole := v == 0
306         b := make([]byte, 0, l)
307
308         for i := len(s) - 1; i >= 0; i-- {
309
310                 if s[i] == '.' {
311                         b = append(b, hy.decimal[0])
312                         inWhole = true
313                         continue
314                 }
315
316                 if inWhole {
317                         if count == 3 {
318                                 for j := len(hy.group) - 1; j >= 0; j-- {
319                                         b = append(b, hy.group[j])
320                                 }
321                                 count = 1
322                         } else {
323                                 count++
324                         }
325                 }
326
327                 b = append(b, s[i])
328         }
329
330         for j := len(symbol) - 1; j >= 0; j-- {
331                 b = append(b, symbol[j])
332         }
333
334         for j := len(hy.currencyPositivePrefix) - 1; j >= 0; j-- {
335                 b = append(b, hy.currencyPositivePrefix[j])
336         }
337
338         if num < 0 {
339                 b = append(b, hy.minus[0])
340         }
341
342         // reverse
343         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
344                 b[i], b[j] = b[j], b[i]
345         }
346
347         if int(v) < 2 {
348
349                 if v == 0 {
350                         b = append(b, hy.decimal...)
351                 }
352
353                 for i := 0; i < 2-int(v); i++ {
354                         b = append(b, '0')
355                 }
356         }
357
358         return string(b)
359 }
360
361 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hy'
362 // in accounting notation.
363 func (hy *hy) FmtAccounting(num float64, v uint64, currency currency.Type) string {
364
365         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
366         symbol := hy.currencies[currency]
367         l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
368         count := 0
369         inWhole := v == 0
370         b := make([]byte, 0, l)
371
372         for i := len(s) - 1; i >= 0; i-- {
373
374                 if s[i] == '.' {
375                         b = append(b, hy.decimal[0])
376                         inWhole = true
377                         continue
378                 }
379
380                 if inWhole {
381                         if count == 3 {
382                                 for j := len(hy.group) - 1; j >= 0; j-- {
383                                         b = append(b, hy.group[j])
384                                 }
385                                 count = 1
386                         } else {
387                                 count++
388                         }
389                 }
390
391                 b = append(b, s[i])
392         }
393
394         if num < 0 {
395
396                 for j := len(symbol) - 1; j >= 0; j-- {
397                         b = append(b, symbol[j])
398                 }
399
400                 for j := len(hy.currencyNegativePrefix) - 1; j >= 0; j-- {
401                         b = append(b, hy.currencyNegativePrefix[j])
402                 }
403
404                 b = append(b, hy.minus[0])
405
406         } else {
407
408                 for j := len(symbol) - 1; j >= 0; j-- {
409                         b = append(b, symbol[j])
410                 }
411
412                 for j := len(hy.currencyPositivePrefix) - 1; j >= 0; j-- {
413                         b = append(b, hy.currencyPositivePrefix[j])
414                 }
415
416         }
417
418         // reverse
419         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
420                 b[i], b[j] = b[j], b[i]
421         }
422
423         if int(v) < 2 {
424
425                 if v == 0 {
426                         b = append(b, hy.decimal...)
427                 }
428
429                 for i := 0; i < 2-int(v); i++ {
430                         b = append(b, '0')
431                 }
432         }
433
434         return string(b)
435 }
436
437 // FmtDateShort returns the short date representation of 't' for 'hy'
438 func (hy *hy) FmtDateShort(t time.Time) string {
439
440         b := make([]byte, 0, 32)
441
442         if t.Day() < 10 {
443                 b = append(b, '0')
444         }
445
446         b = strconv.AppendInt(b, int64(t.Day()), 10)
447         b = append(b, []byte{0x2e}...)
448
449         if t.Month() < 10 {
450                 b = append(b, '0')
451         }
452
453         b = strconv.AppendInt(b, int64(t.Month()), 10)
454
455         b = append(b, []byte{0x2e}...)
456
457         if t.Year() > 9 {
458                 b = append(b, strconv.Itoa(t.Year())[2:]...)
459         } else {
460                 b = append(b, strconv.Itoa(t.Year())[1:]...)
461         }
462
463         return string(b)
464 }
465
466 // FmtDateMedium returns the medium date representation of 't' for 'hy'
467 func (hy *hy) FmtDateMedium(t time.Time) string {
468
469         b := make([]byte, 0, 32)
470
471         if t.Day() < 10 {
472                 b = append(b, '0')
473         }
474
475         b = strconv.AppendInt(b, int64(t.Day()), 10)
476         b = append(b, []byte{0x20}...)
477         b = append(b, hy.monthsAbbreviated[t.Month()]...)
478         b = append(b, []byte{0x2c, 0x20}...)
479
480         if t.Year() > 0 {
481                 b = strconv.AppendInt(b, int64(t.Year()), 10)
482         } else {
483                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
484         }
485
486         b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e}...)
487
488         return string(b)
489 }
490
491 // FmtDateLong returns the long date representation of 't' for 'hy'
492 func (hy *hy) FmtDateLong(t time.Time) string {
493
494         b := make([]byte, 0, 32)
495
496         if t.Day() < 10 {
497                 b = append(b, '0')
498         }
499
500         b = strconv.AppendInt(b, int64(t.Day()), 10)
501         b = append(b, []byte{0x20}...)
502         b = append(b, hy.monthsWide[t.Month()]...)
503         b = append(b, []byte{0x2c, 0x20}...)
504
505         if t.Year() > 0 {
506                 b = strconv.AppendInt(b, int64(t.Year()), 10)
507         } else {
508                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
509         }
510
511         b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e}...)
512
513         return string(b)
514 }
515
516 // FmtDateFull returns the full date representation of 't' for 'hy'
517 func (hy *hy) FmtDateFull(t time.Time) string {
518
519         b := make([]byte, 0, 32)
520
521         if t.Year() > 0 {
522                 b = strconv.AppendInt(b, int64(t.Year()), 10)
523         } else {
524                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
525         }
526
527         b = append(b, []byte{0x20, 0xd5, 0xa9, 0x2e, 0x20}...)
528         b = append(b, hy.monthsWide[t.Month()]...)
529         b = append(b, []byte{0x20}...)
530         b = strconv.AppendInt(b, int64(t.Day()), 10)
531         b = append(b, []byte{0x2c, 0x20}...)
532         b = append(b, hy.daysWide[t.Weekday()]...)
533
534         return string(b)
535 }
536
537 // FmtTimeShort returns the short time representation of 't' for 'hy'
538 func (hy *hy) FmtTimeShort(t time.Time) string {
539
540         b := make([]byte, 0, 32)
541
542         if t.Hour() < 10 {
543                 b = append(b, '0')
544         }
545
546         b = strconv.AppendInt(b, int64(t.Hour()), 10)
547         b = append(b, hy.timeSeparator...)
548
549         if t.Minute() < 10 {
550                 b = append(b, '0')
551         }
552
553         b = strconv.AppendInt(b, int64(t.Minute()), 10)
554
555         return string(b)
556 }
557
558 // FmtTimeMedium returns the medium time representation of 't' for 'hy'
559 func (hy *hy) FmtTimeMedium(t time.Time) string {
560
561         b := make([]byte, 0, 32)
562
563         if t.Hour() < 10 {
564                 b = append(b, '0')
565         }
566
567         b = strconv.AppendInt(b, int64(t.Hour()), 10)
568         b = append(b, hy.timeSeparator...)
569
570         if t.Minute() < 10 {
571                 b = append(b, '0')
572         }
573
574         b = strconv.AppendInt(b, int64(t.Minute()), 10)
575         b = append(b, hy.timeSeparator...)
576
577         if t.Second() < 10 {
578                 b = append(b, '0')
579         }
580
581         b = strconv.AppendInt(b, int64(t.Second()), 10)
582
583         return string(b)
584 }
585
586 // FmtTimeLong returns the long time representation of 't' for 'hy'
587 func (hy *hy) FmtTimeLong(t time.Time) string {
588
589         b := make([]byte, 0, 32)
590
591         if t.Hour() < 10 {
592                 b = append(b, '0')
593         }
594
595         b = strconv.AppendInt(b, int64(t.Hour()), 10)
596         b = append(b, hy.timeSeparator...)
597
598         if t.Minute() < 10 {
599                 b = append(b, '0')
600         }
601
602         b = strconv.AppendInt(b, int64(t.Minute()), 10)
603         b = append(b, hy.timeSeparator...)
604
605         if t.Second() < 10 {
606                 b = append(b, '0')
607         }
608
609         b = strconv.AppendInt(b, int64(t.Second()), 10)
610         b = append(b, []byte{0x20}...)
611
612         tz, _ := t.Zone()
613         b = append(b, tz...)
614
615         return string(b)
616 }
617
618 // FmtTimeFull returns the full time representation of 't' for 'hy'
619 func (hy *hy) FmtTimeFull(t time.Time) string {
620
621         b := make([]byte, 0, 32)
622
623         if t.Hour() < 10 {
624                 b = append(b, '0')
625         }
626
627         b = strconv.AppendInt(b, int64(t.Hour()), 10)
628         b = append(b, hy.timeSeparator...)
629
630         if t.Minute() < 10 {
631                 b = append(b, '0')
632         }
633
634         b = strconv.AppendInt(b, int64(t.Minute()), 10)
635         b = append(b, hy.timeSeparator...)
636
637         if t.Second() < 10 {
638                 b = append(b, '0')
639         }
640
641         b = strconv.AppendInt(b, int64(t.Second()), 10)
642         b = append(b, []byte{0x20}...)
643
644         tz, _ := t.Zone()
645
646         if btz, ok := hy.timezones[tz]; ok {
647                 b = append(b, btz...)
648         } else {
649                 b = append(b, tz...)
650         }
651
652         return string(b)
653 }