OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / go-playground / locales / si / si.go
1 package si
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 si 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         currencyNegativePrefix string
26         currencyNegativeSuffix 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 'si' locale
45 func New() locales.Translator {
46         return &si{
47                 locale:                 "si",
48                 pluralsCardinal:        []locales.PluralRule{2, 6},
49                 pluralsOrdinal:         []locales.PluralRule{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", "AMD", "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", "රු.", "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", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "සිෆ්එ", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
59                 currencyNegativePrefix: "(",
60                 currencyNegativeSuffix: ")",
61                 monthsAbbreviated:      []string{"", "ජන", "පෙබ", "මාර්තු", "අප්\u200dරේල්", "මැයි", "ජූනි", "ජූලි", "අගෝ", "සැප්", "ඔක්", "නොවැ", "දෙසැ"},
62                 monthsNarrow:           []string{"", "ජ", "පෙ", "මා", "අ", "මැ", "ජූ", "ජූ", "අ", "සැ", "ඔ", "නෙ", "දෙ"},
63                 monthsWide:             []string{"", "ජනවාරි", "පෙබරවාරි", "මාර්තු", "අප්\u200dරේල්", "මැයි", "ජූනි", "ජූලි", "අගෝස්තු", "සැප්තැම්බර්", "ඔක්තෝබර්", "නොවැම්බර්", "දෙසැම්බර්"},
64                 daysAbbreviated:        []string{"ඉරිදා", "සඳුදා", "අඟහ", "බදාදා", "බ්\u200dරහස්", "සිකු", "සෙන"},
65                 daysNarrow:             []string{"ඉ", "ස", "අ", "බ", "බ්\u200dර", "සි", "සෙ"},
66                 daysShort:              []string{"ඉරි", "සඳු", "අඟ", "බදා", "බ්\u200dරහ", "සිකු", "සෙන"},
67                 daysWide:               []string{"ඉරිදා", "සඳුදා", "අඟහරුවාදා", "බදාදා", "බ්\u200dරහස්පතින්දා", "සිකුරාදා", "සෙනසුරාදා"},
68                 periodsAbbreviated:     []string{"පෙ.ව.", "ප.ව."},
69                 periodsNarrow:          []string{"පෙ", "ප"},
70                 periodsWide:            []string{"පෙ.ව.", "ප.ව."},
71                 erasAbbreviated:        []string{"ක්\u200dරි.පූ.", "ක්\u200dරි.ව."},
72                 erasNarrow:             []string{"", ""},
73                 erasWide:               []string{"ක්\u200dරිස්තු පූර්ව", "ක්\u200dරිස්තු වර්ෂ"},
74                 timezones:              map[string]string{"OEZ": "නැගෙනහිර යුරෝපීය සම්මත වේලාව", "OESZ": "නැගෙනහිර යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "ADT": "අත්ලාන්තික් දිවාආලෝක වේලාව", "CLT": "චිලී සම්මත වේලාව", "EST": "උතුරු ඇමරිකානු නැගෙනහිර සම්මත වේලාව", "HECU": "කියුබානු දිවාආලෝක වේලාව", "TMST": "ටර්ක්මෙනිස්තාන ග්\u200dරීෂ්ම වේලාව", "AEDT": "නැඟෙනහිර ඕස්ට්\u200dරේලියානු දහවල් වේලාව", "ARST": "ආර්ජන්ටිනා ග්\u200dරීෂ්ම කාලය", "∅∅∅": "ඇමර්සන් ග්\u200dරීෂ්ම කාලය", "MESZ": "මධ්\u200dයම යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "LHST": "ලෝර්ඩ් හෝව් සම්මත වේලාව", "WARST": "බටහිර ආර්ජන්ටිනා ග්\u200dරීෂ්ම කාලය", "ACDT": "මධ්\u200dයම ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "CAT": "මධ්\u200dයම අප්\u200dරිකානු වේලාව", "WIB": "බටහිර ඉන්දුනීසියානු වේලාව", "MST": "MST", "WAT": "බටහිර අප්\u200dරිකානු සම්මත වේලාව", "WAST": "බටහිර අප්\u200dරිකානු ග්\u200dරීෂ්ම කාලය", "CLST": "චිලී ග්\u200dරීෂ්ම කාලය", "EDT": "උතුරු ඇමරිකානු නැගෙනහිර දිවාආලෝක වේලාව", "WIT": "නැගෙනහිර ඉන්දුනීසියානු වේලාව", "NZDT": "නවසීලන්ත දිවා වේලාව", "HNOG": "බටහිර ග්\u200dරීන්ලන්ත සම්මත වේලාව", "AWDT": "බටහිර ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "SRT": "සුරිනාම වේලාව", "ACWDT": "මධ්\u200dයම බටහිර ඔස්ට්\u200dරේලියානු දහවල් වේලාව", "LHDT": "ලෝර්ඩ් හෝව් දිවා වේලාව", "WEZ": "බටහිර යුරෝපීය සම්මත වේලාව", "HNPMX": "මෙක්සිකෝ පැසිෆික් සම්මත වේලාව", "BT": "භුතාන වේලාව", "CDT": "උතුරු ඇමරිකානු මධ්\u200dයම දිවාආලෝක වේලාව", "VET": "වෙනිසියුලා වේලාව", "SAST": "දකුණු අප්\u200dරිකානු වේලාව", "HNEG": "නැගෙනහිර ග්\u200dරීන්ලන්ත සම්මත වේලාව", "HEPM": "ශාන්ත පියරේ සහ මැකෝලන් දිවාආලෝක වේලාව", "AWST": "බටහිර ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "WART": "බටහිර ආර්ජන්ටිනා සම්මත වේලාව", "HEOG": "බටහිර ග්\u200dරීන්ලන්ත ග්\u200dරීෂ්ම කාලය", "AKST": "ඇලස්කා සම්මත වේලාව", "ECT": "ඉක්වදෝර් වේලාව", "HADT": "හවායි-අලෙයුතියාන් දිවාආලෝක වේලාව", "JDT": "ජපාන දහවල් වේලාව", "IST": "ඉන්දියානු වේලාව", "HNT": "නිව්ෆවුන්ලන්ත සම්මත වේලාව", "ACST": "ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "HEPMX": "මෙක්සිකෝ පැසිෆික් දිවාආලෝක වේලාව", "UYT": "උරුගුවේ සම්මත වේලාව", "HNNOMX": "වයඹ මෙක්සිකෝ සම්මත වේලාව", "HENOMX": "වයඹ මෙක්සිකෝ දිවාආලෝක වේලාව", "WITA": "මධ්\u200dයම ඉන්දුනීසියානු වේලාව", "AST": "අත්ලාන්තික් සම්මත වේලාව", "EAT": "නැගෙනහිර අප්\u200dරිකානු වේලාව", "CST": "උතුරු ඇමරිකානු මධ්\u200dයම සම්මත වේලාව", "MDT": "MDT", "TMT": "ටර්ක්මෙනිස්තාන සම්මත වේලාව", "AEST": "නැගෙනහිර ඕස්ට්\u200dරේලියානු සම්මත වේලාව", "HAT": "නිව්ෆවුන්ලන්ත දිවාආලෝක වේලාව", "GMT": "ග්\u200dරිනිච් මධ්\u200dයම වේලාව", "JST": "ජපාන සම්මත වේලාව", "CHADT": "චැතම් දිවා වේලාව", "BOT": "බොලිවියා වේලාව", "COST": "කොලොම්බියා ග්\u200dරීෂ්ම කාලය", "ChST": "චමොරෝ වේලාව", "MYT": "මැලේසියානු වේලාව", "HNPM": "ශාන්ත පියරේ සහ මැකෝලන් සම්මත වේලාව", "MEZ": "මධ්\u200dයම යුරෝපීය සම්මත වේලාව", "HAST": "හවායි-අලෙයුතියාන් සම්මත වේලාව", "ART": "ආර්ජන්ටිනා සම්මත වේලාව", "HKST": "හොංකොං ග්\u200dරීෂ්ම වේලාව", "SGT": "සිංගප්පුරු වේලාව", "PDT": "උතුරු ඇමරිකානු පැසිෆික් දිවාආලෝක වේලාව", "HNCU": "කියුබානු සම්මත වේලාව", "AKDT": "ඇලස්කා දිවාආලෝක වේලාව", "PST": "උතුරු ඇමරිකානු පැසිෆික් සම්මත වේලාව", "ACWST": "මධ්\u200dයම බටහිර ඔස්ට්\u200dරේලියානු සම්මත වේලාව", "HEEG": "නැගෙනහිර ග්\u200dරීන්ලන්ත ග්\u200dරීෂ්ම කාලය", "HKT": "හොංකොං සම්මත වේලාව", "GFT": "ප්\u200dරංශ ගයනා වේලාව", "WESZ": "බටහිර යුරෝපීය ග්\u200dරීෂ්ම වේලාව", "COT": "කොලොම්බියා සම්මත වේලාව", "GYT": "ගයනා වේලාව", "CHAST": "චැතම් සම්මත වේලාව", "NZST": "නවසීලන්ත සම්මත වේලාව", "UYST": "උරුගුවේ ග්\u200dරීෂ්ම කාලය"},
75         }
76 }
77
78 // Locale returns the current translators string locale
79 func (si *si) Locale() string {
80         return si.locale
81 }
82
83 // PluralsCardinal returns the list of cardinal plural rules associated with 'si'
84 func (si *si) PluralsCardinal() []locales.PluralRule {
85         return si.pluralsCardinal
86 }
87
88 // PluralsOrdinal returns the list of ordinal plural rules associated with 'si'
89 func (si *si) PluralsOrdinal() []locales.PluralRule {
90         return si.pluralsOrdinal
91 }
92
93 // PluralsRange returns the list of range plural rules associated with 'si'
94 func (si *si) PluralsRange() []locales.PluralRule {
95         return si.pluralsRange
96 }
97
98 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'si'
99 func (si *si) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100
101         n := math.Abs(num)
102         i := int64(n)
103         f := locales.F(n, v)
104
105         if (n == 0 || n == 1) || (i == 0 && f == 1) {
106                 return locales.PluralRuleOne
107         }
108
109         return locales.PluralRuleOther
110 }
111
112 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'si'
113 func (si *si) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
114         return locales.PluralRuleOther
115 }
116
117 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'si'
118 func (si *si) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
119
120         start := si.CardinalPluralRule(num1, v1)
121         end := si.CardinalPluralRule(num2, v2)
122
123         if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
124                 return locales.PluralRuleOne
125         } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
126                 return locales.PluralRuleOther
127         } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
128                 return locales.PluralRuleOther
129         }
130
131         return locales.PluralRuleOther
132
133 }
134
135 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
136 func (si *si) MonthAbbreviated(month time.Month) string {
137         return si.monthsAbbreviated[month]
138 }
139
140 // MonthsAbbreviated returns the locales abbreviated months
141 func (si *si) MonthsAbbreviated() []string {
142         return si.monthsAbbreviated[1:]
143 }
144
145 // MonthNarrow returns the locales narrow month given the 'month' provided
146 func (si *si) MonthNarrow(month time.Month) string {
147         return si.monthsNarrow[month]
148 }
149
150 // MonthsNarrow returns the locales narrow months
151 func (si *si) MonthsNarrow() []string {
152         return si.monthsNarrow[1:]
153 }
154
155 // MonthWide returns the locales wide month given the 'month' provided
156 func (si *si) MonthWide(month time.Month) string {
157         return si.monthsWide[month]
158 }
159
160 // MonthsWide returns the locales wide months
161 func (si *si) MonthsWide() []string {
162         return si.monthsWide[1:]
163 }
164
165 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
166 func (si *si) WeekdayAbbreviated(weekday time.Weekday) string {
167         return si.daysAbbreviated[weekday]
168 }
169
170 // WeekdaysAbbreviated returns the locales abbreviated weekdays
171 func (si *si) WeekdaysAbbreviated() []string {
172         return si.daysAbbreviated
173 }
174
175 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
176 func (si *si) WeekdayNarrow(weekday time.Weekday) string {
177         return si.daysNarrow[weekday]
178 }
179
180 // WeekdaysNarrow returns the locales narrow weekdays
181 func (si *si) WeekdaysNarrow() []string {
182         return si.daysNarrow
183 }
184
185 // WeekdayShort returns the locales short weekday given the 'weekday' provided
186 func (si *si) WeekdayShort(weekday time.Weekday) string {
187         return si.daysShort[weekday]
188 }
189
190 // WeekdaysShort returns the locales short weekdays
191 func (si *si) WeekdaysShort() []string {
192         return si.daysShort
193 }
194
195 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
196 func (si *si) WeekdayWide(weekday time.Weekday) string {
197         return si.daysWide[weekday]
198 }
199
200 // WeekdaysWide returns the locales wide weekdays
201 func (si *si) WeekdaysWide() []string {
202         return si.daysWide
203 }
204
205 // Decimal returns the decimal point of number
206 func (si *si) Decimal() string {
207         return si.decimal
208 }
209
210 // Group returns the group of number
211 func (si *si) Group() string {
212         return si.group
213 }
214
215 // Group returns the minus sign of number
216 func (si *si) Minus() string {
217         return si.minus
218 }
219
220 // FmtNumber returns 'num' with digits/precision of 'v' for 'si' and handles both Whole and Real numbers based on 'v'
221 func (si *si) FmtNumber(num float64, v uint64) string {
222
223         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
224         l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
225         count := 0
226         inWhole := v == 0
227         b := make([]byte, 0, l)
228
229         for i := len(s) - 1; i >= 0; i-- {
230
231                 if s[i] == '.' {
232                         b = append(b, si.decimal[0])
233                         inWhole = true
234                         continue
235                 }
236
237                 if inWhole {
238                         if count == 3 {
239                                 b = append(b, si.group[0])
240                                 count = 1
241                         } else {
242                                 count++
243                         }
244                 }
245
246                 b = append(b, s[i])
247         }
248
249         if num < 0 {
250                 b = append(b, si.minus[0])
251         }
252
253         // reverse
254         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
255                 b[i], b[j] = b[j], b[i]
256         }
257
258         return string(b)
259 }
260
261 // FmtPercent returns 'num' with digits/precision of 'v' for 'si' and handles both Whole and Real numbers based on 'v'
262 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
263 func (si *si) FmtPercent(num float64, v uint64) string {
264         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
265         l := len(s) + 3
266         b := make([]byte, 0, l)
267
268         for i := len(s) - 1; i >= 0; i-- {
269
270                 if s[i] == '.' {
271                         b = append(b, si.decimal[0])
272                         continue
273                 }
274
275                 b = append(b, s[i])
276         }
277
278         if num < 0 {
279                 b = append(b, si.minus[0])
280         }
281
282         // reverse
283         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
284                 b[i], b[j] = b[j], b[i]
285         }
286
287         b = append(b, si.percent...)
288
289         return string(b)
290 }
291
292 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'si'
293 func (si *si) FmtCurrency(num float64, v uint64, currency currency.Type) string {
294
295         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
296         symbol := si.currencies[currency]
297         l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
298         count := 0
299         inWhole := v == 0
300         b := make([]byte, 0, l)
301
302         for i := len(s) - 1; i >= 0; i-- {
303
304                 if s[i] == '.' {
305                         b = append(b, si.decimal[0])
306                         inWhole = true
307                         continue
308                 }
309
310                 if inWhole {
311                         if count == 3 {
312                                 b = append(b, si.group[0])
313                                 count = 1
314                         } else {
315                                 count++
316                         }
317                 }
318
319                 b = append(b, s[i])
320         }
321
322         for j := len(symbol) - 1; j >= 0; j-- {
323                 b = append(b, symbol[j])
324         }
325
326         if num < 0 {
327                 b = append(b, si.minus[0])
328         }
329
330         // reverse
331         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
332                 b[i], b[j] = b[j], b[i]
333         }
334
335         if int(v) < 2 {
336
337                 if v == 0 {
338                         b = append(b, si.decimal...)
339                 }
340
341                 for i := 0; i < 2-int(v); i++ {
342                         b = append(b, '0')
343                 }
344         }
345
346         return string(b)
347 }
348
349 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'si'
350 // in accounting notation.
351 func (si *si) FmtAccounting(num float64, v uint64, currency currency.Type) string {
352
353         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
354         symbol := si.currencies[currency]
355         l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
356         count := 0
357         inWhole := v == 0
358         b := make([]byte, 0, l)
359
360         for i := len(s) - 1; i >= 0; i-- {
361
362                 if s[i] == '.' {
363                         b = append(b, si.decimal[0])
364                         inWhole = true
365                         continue
366                 }
367
368                 if inWhole {
369                         if count == 3 {
370                                 b = append(b, si.group[0])
371                                 count = 1
372                         } else {
373                                 count++
374                         }
375                 }
376
377                 b = append(b, s[i])
378         }
379
380         if num < 0 {
381
382                 for j := len(symbol) - 1; j >= 0; j-- {
383                         b = append(b, symbol[j])
384                 }
385
386                 b = append(b, si.currencyNegativePrefix[0])
387
388         } else {
389
390                 for j := len(symbol) - 1; j >= 0; j-- {
391                         b = append(b, symbol[j])
392                 }
393
394         }
395
396         // reverse
397         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
398                 b[i], b[j] = b[j], b[i]
399         }
400
401         if int(v) < 2 {
402
403                 if v == 0 {
404                         b = append(b, si.decimal...)
405                 }
406
407                 for i := 0; i < 2-int(v); i++ {
408                         b = append(b, '0')
409                 }
410         }
411
412         if num < 0 {
413                 b = append(b, si.currencyNegativeSuffix...)
414         }
415
416         return string(b)
417 }
418
419 // FmtDateShort returns the short date representation of 't' for 'si'
420 func (si *si) FmtDateShort(t time.Time) string {
421
422         b := make([]byte, 0, 32)
423
424         if t.Year() > 0 {
425                 b = strconv.AppendInt(b, int64(t.Year()), 10)
426         } else {
427                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
428         }
429
430         b = append(b, []byte{0x2d}...)
431
432         if t.Month() < 10 {
433                 b = append(b, '0')
434         }
435
436         b = strconv.AppendInt(b, int64(t.Month()), 10)
437
438         b = append(b, []byte{0x2d}...)
439
440         if t.Day() < 10 {
441                 b = append(b, '0')
442         }
443
444         b = strconv.AppendInt(b, int64(t.Day()), 10)
445
446         return string(b)
447 }
448
449 // FmtDateMedium returns the medium date representation of 't' for 'si'
450 func (si *si) FmtDateMedium(t time.Time) string {
451
452         b := make([]byte, 0, 32)
453
454         if t.Year() > 0 {
455                 b = strconv.AppendInt(b, int64(t.Year()), 10)
456         } else {
457                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
458         }
459
460         b = append(b, []byte{0x20}...)
461         b = append(b, si.monthsAbbreviated[t.Month()]...)
462         b = append(b, []byte{0x20}...)
463         b = strconv.AppendInt(b, int64(t.Day()), 10)
464
465         return string(b)
466 }
467
468 // FmtDateLong returns the long date representation of 't' for 'si'
469 func (si *si) FmtDateLong(t time.Time) string {
470
471         b := make([]byte, 0, 32)
472
473         if t.Year() > 0 {
474                 b = strconv.AppendInt(b, int64(t.Year()), 10)
475         } else {
476                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
477         }
478
479         b = append(b, []byte{0x20}...)
480         b = append(b, si.monthsWide[t.Month()]...)
481         b = append(b, []byte{0x20}...)
482         b = strconv.AppendInt(b, int64(t.Day()), 10)
483
484         return string(b)
485 }
486
487 // FmtDateFull returns the full date representation of 't' for 'si'
488 func (si *si) FmtDateFull(t time.Time) string {
489
490         b := make([]byte, 0, 32)
491
492         if t.Year() > 0 {
493                 b = strconv.AppendInt(b, int64(t.Year()), 10)
494         } else {
495                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
496         }
497
498         b = append(b, []byte{0x20}...)
499         b = append(b, si.monthsWide[t.Month()]...)
500         b = append(b, []byte{0x20}...)
501         b = strconv.AppendInt(b, int64(t.Day()), 10)
502         b = append(b, []byte{0x2c, 0x20}...)
503         b = append(b, si.daysWide[t.Weekday()]...)
504
505         return string(b)
506 }
507
508 // FmtTimeShort returns the short time representation of 't' for 'si'
509 func (si *si) FmtTimeShort(t time.Time) string {
510
511         b := make([]byte, 0, 32)
512
513         if t.Hour() < 10 {
514                 b = append(b, '0')
515         }
516
517         b = strconv.AppendInt(b, int64(t.Hour()), 10)
518         b = append(b, []byte{0x2e}...)
519
520         if t.Minute() < 10 {
521                 b = append(b, '0')
522         }
523
524         b = strconv.AppendInt(b, int64(t.Minute()), 10)
525
526         return string(b)
527 }
528
529 // FmtTimeMedium returns the medium time representation of 't' for 'si'
530 func (si *si) FmtTimeMedium(t time.Time) string {
531
532         b := make([]byte, 0, 32)
533
534         if t.Hour() < 10 {
535                 b = append(b, '0')
536         }
537
538         b = strconv.AppendInt(b, int64(t.Hour()), 10)
539         b = append(b, []byte{0x2e}...)
540
541         if t.Minute() < 10 {
542                 b = append(b, '0')
543         }
544
545         b = strconv.AppendInt(b, int64(t.Minute()), 10)
546         b = append(b, []byte{0x2e}...)
547
548         if t.Second() < 10 {
549                 b = append(b, '0')
550         }
551
552         b = strconv.AppendInt(b, int64(t.Second()), 10)
553
554         return string(b)
555 }
556
557 // FmtTimeLong returns the long time representation of 't' for 'si'
558 func (si *si) FmtTimeLong(t time.Time) string {
559
560         b := make([]byte, 0, 32)
561
562         if t.Hour() < 10 {
563                 b = append(b, '0')
564         }
565
566         b = strconv.AppendInt(b, int64(t.Hour()), 10)
567         b = append(b, []byte{0x2e}...)
568
569         if t.Minute() < 10 {
570                 b = append(b, '0')
571         }
572
573         b = strconv.AppendInt(b, int64(t.Minute()), 10)
574         b = append(b, []byte{0x2e}...)
575
576         if t.Second() < 10 {
577                 b = append(b, '0')
578         }
579
580         b = strconv.AppendInt(b, int64(t.Second()), 10)
581         b = append(b, []byte{0x20}...)
582
583         tz, _ := t.Zone()
584         b = append(b, tz...)
585
586         return string(b)
587 }
588
589 // FmtTimeFull returns the full time representation of 't' for 'si'
590 func (si *si) FmtTimeFull(t time.Time) string {
591
592         b := make([]byte, 0, 32)
593
594         if t.Hour() < 10 {
595                 b = append(b, '0')
596         }
597
598         b = strconv.AppendInt(b, int64(t.Hour()), 10)
599         b = append(b, []byte{0x2e}...)
600
601         if t.Minute() < 10 {
602                 b = append(b, '0')
603         }
604
605         b = strconv.AppendInt(b, int64(t.Minute()), 10)
606         b = append(b, []byte{0x2e}...)
607
608         if t.Second() < 10 {
609                 b = append(b, '0')
610         }
611
612         b = strconv.AppendInt(b, int64(t.Second()), 10)
613         b = append(b, []byte{0x20}...)
614
615         tz, _ := t.Zone()
616
617         if btz, ok := si.timezones[tz]; ok {
618                 b = append(b, btz...)
619         } else {
620                 b = append(b, tz...)
621         }
622
623         return string(b)
624 }