1package ms
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/go-playground/locales"
9	"github.com/go-playground/locales/currency"
10)
11
12type ms 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 'ms' locale
45func New() locales.Translator {
46	return &ms{
47		locale:                 "ms",
48		pluralsCardinal:        []locales.PluralRule{6},
49		pluralsOrdinal:         []locales.PluralRule{2, 6},
50		pluralsRange:           []locales.PluralRule{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", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "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", "MXN", "MXP", "MXV", "RM", "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", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "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		currencyNegativePrefix: "(",
60		currencyNegativeSuffix: ")",
61		monthsAbbreviated:      []string{"", "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis"},
62		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "O", "S", "O", "N", "D"},
63		monthsWide:             []string{"", "Januari", "Februari", "Mac", "April", "Mei", "Jun", "Julai", "Ogos", "September", "Oktober", "November", "Disember"},
64		daysAbbreviated:        []string{"Ahd", "Isn", "Sel", "Rab", "Kha", "Jum", "Sab"},
65		daysNarrow:             []string{"A", "I", "S", "R", "K", "J", "S"},
66		daysShort:              []string{"Ah", "Is", "Se", "Ra", "Kh", "Ju", "Sa"},
67		daysWide:               []string{"Ahad", "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu"},
68		periodsAbbreviated:     []string{"PG", "PTG"},
69		periodsNarrow:          []string{"a", "p"},
70		periodsWide:            []string{"PG", "PTG"},
71		erasAbbreviated:        []string{"S.M.", "TM"},
72		erasNarrow:             []string{"S.M.", "TM"},
73		erasWide:               []string{"S.M.", "TM"},
74		timezones:              map[string]string{"CHADT": "Waktu Siang Chatham", "MESZ": "Waktu Musim Panas Eropah Tengah", "SRT": "Waktu Suriname", "CAT": "Waktu Afrika Tengah", "WIT": "Waktu Indonesia Timur", "HECU": "Waktu Siang Cuba", "AWDT": "Waktu Siang Australia Barat", "JDT": "Waktu Siang Jepun", "∅∅∅": "Waktu Musim Panas Brasilia", "AWST": "Waktu Piawai Australia Barat", "HEEG": "Waktu Musim Panas Greenland Timur", "TMT": "Waktu Piawai Turkmenistan", "GMT": "Waktu Min Greenwich", "ACWST": "Waktu Piawai Barat Tengah Australia", "HNEG": "Waktu Piawai Greenland Timur", "LHDT": "Waktu Siang Lord Howe", "HNPM": "Waktu Piawai Saint Pierre dan Miquelon", "EAT": "Waktu Afrika Timur", "ART": "Waktu Piawai Argentina", "GYT": "Waktu Guyana", "CHAST": "Waktu Piawai Chatham", "PST": "Waktu Piawai Pasifik", "HEPMX": "Waktu Siang Pasifik Mexico", "AEDT": "Waktu Siang Australia Timur", "HEOG": "Waktu Musim Panas Greenland Barat", "MEZ": "Waktu Piawai Eropah Tengah", "HKT": "Waktu Piawai Hong Kong", "HNNOMX": "Waktu Piawai Barat Laut Mexico", "CLT": "Waktu Piawai Chile", "UYST": "Waktu Musim Panas Uruguay", "ADT": "Waktu Siang Atlantik", "MDT": "Waktu Hari Siang Pergunungan", "SAST": "Waktu Piawai Afrika Selatan", "EST": "Waktu Piawai Timur", "OEZ": "Waktu Piawai Eropah Timur", "WAST": "Waktu Musim Panas Afrika Barat", "OESZ": "Waktu Musim Panas Eropah Timur", "CDT": "Waktu Siang Tengah", "AST": "Waktu Piawai Atlantik", "BT": "Waktu Bhutan", "HNOG": "Waktu Piawai Greenland Barat", "WARST": "Waktu Musim Panas Argentina Barat", "CLST": "Waktu Musim Panas Chile", "HADT": "Waktu Siang Hawaii-Aleutian", "BOT": "Waktu Bolivia", "GFT": "Waktu Guyana Perancis", "HAT": "Waktu Siang Newfoundland", "COST": "Waktu Musim Panas Colombia", "HNCU": "Waktu Piawai Cuba", "WIB": "Waktu Indonesia Barat", "NZST": "Waktu Piawai New Zealand", "NZDT": "Waktu Siang New Zealand", "MYT": "Waktu Malaysia", "EDT": "Waktu Siang Timur", "ACST": "Waktu Piawai Australia Tengah", "WART": "Waktu Piawai Argentina Barat", "ChST": "Waktu Piawai Chamorro", "AKST": "Waktu Piawai Alaska", "ACWDT": "Waktu Siang Barat Tengah Australia", "WITA": "Waktu Indonesia Tengah", "COT": "Waktu Piawai Colombia", "PDT": "Waktu Siang Pasifik", "WESZ": "Waktu Musim Panas Eropah Barat", "ECT": "Waktu Ecuador", "IST": "Waktu Piawai India", "HENOMX": "Waktu Siang Barat Laut Mexico", "TMST": "Waktu Musim Panas Turkmenistan", "UYT": "Waktu Piawai Uruguay", "CST": "Waktu Piawai Pusat", "WAT": "Waktu Piawai Afrika Barat", "WEZ": "Waktu Piawai Eropah Barat", "JST": "Waktu Piawai Jepun", "SGT": "Waktu Piawai Singapura", "HKST": "Waktu Musim Panas Hong Kong", "LHST": "Waktu Piawai Lord Howe", "HNT": "Waktu Piawai Newfoundland", "VET": "Waktu Venezuela", "ARST": "Waktu Musim Panas Argentina", "AEST": "Waktu Piawai Timur Australia", "AKDT": "Waktu Siang Alaska", "HEPM": "Waktu Siang Saint Pierre dan Miquelon", "HNPMX": "Waktu Piawai Pasifik Mexico", "MST": "Waktu Piawai Pergunungan", "ACDT": "Waktu Siang Australia Tengah", "HAST": "Waktu Piawai Hawaii-Aleutian"},
75	}
76}
77
78// Locale returns the current translators string locale
79func (ms *ms) Locale() string {
80	return ms.locale
81}
82
83// PluralsCardinal returns the list of cardinal plural rules associated with 'ms'
84func (ms *ms) PluralsCardinal() []locales.PluralRule {
85	return ms.pluralsCardinal
86}
87
88// PluralsOrdinal returns the list of ordinal plural rules associated with 'ms'
89func (ms *ms) PluralsOrdinal() []locales.PluralRule {
90	return ms.pluralsOrdinal
91}
92
93// PluralsRange returns the list of range plural rules associated with 'ms'
94func (ms *ms) PluralsRange() []locales.PluralRule {
95	return ms.pluralsRange
96}
97
98// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ms'
99func (ms *ms) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100	return locales.PluralRuleOther
101}
102
103// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ms'
104func (ms *ms) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
105
106	n := math.Abs(num)
107
108	if n == 1 {
109		return locales.PluralRuleOne
110	}
111
112	return locales.PluralRuleOther
113}
114
115// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ms'
116func (ms *ms) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
117	return locales.PluralRuleOther
118}
119
120// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
121func (ms *ms) MonthAbbreviated(month time.Month) string {
122	return ms.monthsAbbreviated[month]
123}
124
125// MonthsAbbreviated returns the locales abbreviated months
126func (ms *ms) MonthsAbbreviated() []string {
127	return ms.monthsAbbreviated[1:]
128}
129
130// MonthNarrow returns the locales narrow month given the 'month' provided
131func (ms *ms) MonthNarrow(month time.Month) string {
132	return ms.monthsNarrow[month]
133}
134
135// MonthsNarrow returns the locales narrow months
136func (ms *ms) MonthsNarrow() []string {
137	return ms.monthsNarrow[1:]
138}
139
140// MonthWide returns the locales wide month given the 'month' provided
141func (ms *ms) MonthWide(month time.Month) string {
142	return ms.monthsWide[month]
143}
144
145// MonthsWide returns the locales wide months
146func (ms *ms) MonthsWide() []string {
147	return ms.monthsWide[1:]
148}
149
150// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
151func (ms *ms) WeekdayAbbreviated(weekday time.Weekday) string {
152	return ms.daysAbbreviated[weekday]
153}
154
155// WeekdaysAbbreviated returns the locales abbreviated weekdays
156func (ms *ms) WeekdaysAbbreviated() []string {
157	return ms.daysAbbreviated
158}
159
160// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
161func (ms *ms) WeekdayNarrow(weekday time.Weekday) string {
162	return ms.daysNarrow[weekday]
163}
164
165// WeekdaysNarrow returns the locales narrow weekdays
166func (ms *ms) WeekdaysNarrow() []string {
167	return ms.daysNarrow
168}
169
170// WeekdayShort returns the locales short weekday given the 'weekday' provided
171func (ms *ms) WeekdayShort(weekday time.Weekday) string {
172	return ms.daysShort[weekday]
173}
174
175// WeekdaysShort returns the locales short weekdays
176func (ms *ms) WeekdaysShort() []string {
177	return ms.daysShort
178}
179
180// WeekdayWide returns the locales wide weekday given the 'weekday' provided
181func (ms *ms) WeekdayWide(weekday time.Weekday) string {
182	return ms.daysWide[weekday]
183}
184
185// WeekdaysWide returns the locales wide weekdays
186func (ms *ms) WeekdaysWide() []string {
187	return ms.daysWide
188}
189
190// Decimal returns the decimal point of number
191func (ms *ms) Decimal() string {
192	return ms.decimal
193}
194
195// Group returns the group of number
196func (ms *ms) Group() string {
197	return ms.group
198}
199
200// Group returns the minus sign of number
201func (ms *ms) Minus() string {
202	return ms.minus
203}
204
205// FmtNumber returns 'num' with digits/precision of 'v' for 'ms' and handles both Whole and Real numbers based on 'v'
206func (ms *ms) FmtNumber(num float64, v uint64) string {
207
208	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
209	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
210	count := 0
211	inWhole := v == 0
212	b := make([]byte, 0, l)
213
214	for i := len(s) - 1; i >= 0; i-- {
215
216		if s[i] == '.' {
217			b = append(b, ms.decimal[0])
218			inWhole = true
219			continue
220		}
221
222		if inWhole {
223			if count == 3 {
224				b = append(b, ms.group[0])
225				count = 1
226			} else {
227				count++
228			}
229		}
230
231		b = append(b, s[i])
232	}
233
234	if num < 0 {
235		b = append(b, ms.minus[0])
236	}
237
238	// reverse
239	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
240		b[i], b[j] = b[j], b[i]
241	}
242
243	return string(b)
244}
245
246// FmtPercent returns 'num' with digits/precision of 'v' for 'ms' and handles both Whole and Real numbers based on 'v'
247// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
248func (ms *ms) FmtPercent(num float64, v uint64) string {
249	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
250	l := len(s) + 3
251	b := make([]byte, 0, l)
252
253	for i := len(s) - 1; i >= 0; i-- {
254
255		if s[i] == '.' {
256			b = append(b, ms.decimal[0])
257			continue
258		}
259
260		b = append(b, s[i])
261	}
262
263	if num < 0 {
264		b = append(b, ms.minus[0])
265	}
266
267	// reverse
268	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
269		b[i], b[j] = b[j], b[i]
270	}
271
272	b = append(b, ms.percent...)
273
274	return string(b)
275}
276
277// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ms'
278func (ms *ms) FmtCurrency(num float64, v uint64, currency currency.Type) string {
279
280	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
281	symbol := ms.currencies[currency]
282	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
283	count := 0
284	inWhole := v == 0
285	b := make([]byte, 0, l)
286
287	for i := len(s) - 1; i >= 0; i-- {
288
289		if s[i] == '.' {
290			b = append(b, ms.decimal[0])
291			inWhole = true
292			continue
293		}
294
295		if inWhole {
296			if count == 3 {
297				b = append(b, ms.group[0])
298				count = 1
299			} else {
300				count++
301			}
302		}
303
304		b = append(b, s[i])
305	}
306
307	for j := len(symbol) - 1; j >= 0; j-- {
308		b = append(b, symbol[j])
309	}
310
311	if num < 0 {
312		b = append(b, ms.minus[0])
313	}
314
315	// reverse
316	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
317		b[i], b[j] = b[j], b[i]
318	}
319
320	if int(v) < 2 {
321
322		if v == 0 {
323			b = append(b, ms.decimal...)
324		}
325
326		for i := 0; i < 2-int(v); i++ {
327			b = append(b, '0')
328		}
329	}
330
331	return string(b)
332}
333
334// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ms'
335// in accounting notation.
336func (ms *ms) FmtAccounting(num float64, v uint64, currency currency.Type) string {
337
338	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
339	symbol := ms.currencies[currency]
340	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
341	count := 0
342	inWhole := v == 0
343	b := make([]byte, 0, l)
344
345	for i := len(s) - 1; i >= 0; i-- {
346
347		if s[i] == '.' {
348			b = append(b, ms.decimal[0])
349			inWhole = true
350			continue
351		}
352
353		if inWhole {
354			if count == 3 {
355				b = append(b, ms.group[0])
356				count = 1
357			} else {
358				count++
359			}
360		}
361
362		b = append(b, s[i])
363	}
364
365	if num < 0 {
366
367		for j := len(symbol) - 1; j >= 0; j-- {
368			b = append(b, symbol[j])
369		}
370
371		b = append(b, ms.currencyNegativePrefix[0])
372
373	} else {
374
375		for j := len(symbol) - 1; j >= 0; j-- {
376			b = append(b, symbol[j])
377		}
378
379	}
380
381	// reverse
382	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
383		b[i], b[j] = b[j], b[i]
384	}
385
386	if int(v) < 2 {
387
388		if v == 0 {
389			b = append(b, ms.decimal...)
390		}
391
392		for i := 0; i < 2-int(v); i++ {
393			b = append(b, '0')
394		}
395	}
396
397	if num < 0 {
398		b = append(b, ms.currencyNegativeSuffix...)
399	}
400
401	return string(b)
402}
403
404// FmtDateShort returns the short date representation of 't' for 'ms'
405func (ms *ms) FmtDateShort(t time.Time) string {
406
407	b := make([]byte, 0, 32)
408
409	b = strconv.AppendInt(b, int64(t.Day()), 10)
410	b = append(b, []byte{0x2f}...)
411
412	if t.Month() < 10 {
413		b = append(b, '0')
414	}
415
416	b = strconv.AppendInt(b, int64(t.Month()), 10)
417
418	b = append(b, []byte{0x2f}...)
419
420	if t.Year() > 9 {
421		b = append(b, strconv.Itoa(t.Year())[2:]...)
422	} else {
423		b = append(b, strconv.Itoa(t.Year())[1:]...)
424	}
425
426	return string(b)
427}
428
429// FmtDateMedium returns the medium date representation of 't' for 'ms'
430func (ms *ms) FmtDateMedium(t time.Time) string {
431
432	b := make([]byte, 0, 32)
433
434	b = strconv.AppendInt(b, int64(t.Day()), 10)
435	b = append(b, []byte{0x20}...)
436	b = append(b, ms.monthsAbbreviated[t.Month()]...)
437	b = append(b, []byte{0x20}...)
438
439	if t.Year() > 0 {
440		b = strconv.AppendInt(b, int64(t.Year()), 10)
441	} else {
442		b = strconv.AppendInt(b, int64(-t.Year()), 10)
443	}
444
445	return string(b)
446}
447
448// FmtDateLong returns the long date representation of 't' for 'ms'
449func (ms *ms) FmtDateLong(t time.Time) string {
450
451	b := make([]byte, 0, 32)
452
453	b = strconv.AppendInt(b, int64(t.Day()), 10)
454	b = append(b, []byte{0x20}...)
455	b = append(b, ms.monthsWide[t.Month()]...)
456	b = append(b, []byte{0x20}...)
457
458	if t.Year() > 0 {
459		b = strconv.AppendInt(b, int64(t.Year()), 10)
460	} else {
461		b = strconv.AppendInt(b, int64(-t.Year()), 10)
462	}
463
464	return string(b)
465}
466
467// FmtDateFull returns the full date representation of 't' for 'ms'
468func (ms *ms) FmtDateFull(t time.Time) string {
469
470	b := make([]byte, 0, 32)
471
472	b = append(b, ms.daysWide[t.Weekday()]...)
473	b = append(b, []byte{0x2c, 0x20}...)
474	b = strconv.AppendInt(b, int64(t.Day()), 10)
475	b = append(b, []byte{0x20}...)
476	b = append(b, ms.monthsWide[t.Month()]...)
477	b = append(b, []byte{0x20}...)
478
479	if t.Year() > 0 {
480		b = strconv.AppendInt(b, int64(t.Year()), 10)
481	} else {
482		b = strconv.AppendInt(b, int64(-t.Year()), 10)
483	}
484
485	return string(b)
486}
487
488// FmtTimeShort returns the short time representation of 't' for 'ms'
489func (ms *ms) FmtTimeShort(t time.Time) string {
490
491	b := make([]byte, 0, 32)
492
493	h := t.Hour()
494
495	if h > 12 {
496		h -= 12
497	}
498
499	b = strconv.AppendInt(b, int64(h), 10)
500	b = append(b, ms.timeSeparator...)
501
502	if t.Minute() < 10 {
503		b = append(b, '0')
504	}
505
506	b = strconv.AppendInt(b, int64(t.Minute()), 10)
507	b = append(b, []byte{0x20}...)
508
509	if t.Hour() < 12 {
510		b = append(b, ms.periodsAbbreviated[0]...)
511	} else {
512		b = append(b, ms.periodsAbbreviated[1]...)
513	}
514
515	return string(b)
516}
517
518// FmtTimeMedium returns the medium time representation of 't' for 'ms'
519func (ms *ms) FmtTimeMedium(t time.Time) string {
520
521	b := make([]byte, 0, 32)
522
523	h := t.Hour()
524
525	if h > 12 {
526		h -= 12
527	}
528
529	b = strconv.AppendInt(b, int64(h), 10)
530	b = append(b, ms.timeSeparator...)
531
532	if t.Minute() < 10 {
533		b = append(b, '0')
534	}
535
536	b = strconv.AppendInt(b, int64(t.Minute()), 10)
537	b = append(b, ms.timeSeparator...)
538
539	if t.Second() < 10 {
540		b = append(b, '0')
541	}
542
543	b = strconv.AppendInt(b, int64(t.Second()), 10)
544	b = append(b, []byte{0x20}...)
545
546	if t.Hour() < 12 {
547		b = append(b, ms.periodsAbbreviated[0]...)
548	} else {
549		b = append(b, ms.periodsAbbreviated[1]...)
550	}
551
552	return string(b)
553}
554
555// FmtTimeLong returns the long time representation of 't' for 'ms'
556func (ms *ms) FmtTimeLong(t time.Time) string {
557
558	b := make([]byte, 0, 32)
559
560	h := t.Hour()
561
562	if h > 12 {
563		h -= 12
564	}
565
566	b = strconv.AppendInt(b, int64(h), 10)
567	b = append(b, ms.timeSeparator...)
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, ms.timeSeparator...)
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	if t.Hour() < 12 {
584		b = append(b, ms.periodsAbbreviated[0]...)
585	} else {
586		b = append(b, ms.periodsAbbreviated[1]...)
587	}
588
589	b = append(b, []byte{0x20}...)
590
591	tz, _ := t.Zone()
592	b = append(b, tz...)
593
594	return string(b)
595}
596
597// FmtTimeFull returns the full time representation of 't' for 'ms'
598func (ms *ms) FmtTimeFull(t time.Time) string {
599
600	b := make([]byte, 0, 32)
601
602	h := t.Hour()
603
604	if h > 12 {
605		h -= 12
606	}
607
608	b = strconv.AppendInt(b, int64(h), 10)
609	b = append(b, ms.timeSeparator...)
610
611	if t.Minute() < 10 {
612		b = append(b, '0')
613	}
614
615	b = strconv.AppendInt(b, int64(t.Minute()), 10)
616	b = append(b, ms.timeSeparator...)
617
618	if t.Second() < 10 {
619		b = append(b, '0')
620	}
621
622	b = strconv.AppendInt(b, int64(t.Second()), 10)
623	b = append(b, []byte{0x20}...)
624
625	if t.Hour() < 12 {
626		b = append(b, ms.periodsAbbreviated[0]...)
627	} else {
628		b = append(b, ms.periodsAbbreviated[1]...)
629	}
630
631	b = append(b, []byte{0x20}...)
632
633	tz, _ := t.Zone()
634
635	if btz, ok := ms.timezones[tz]; ok {
636		b = append(b, btz...)
637	} else {
638		b = append(b, tz...)
639	}
640
641	return string(b)
642}
643