ms.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. package ms
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type ms struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal []byte
  15. group []byte
  16. minus []byte
  17. percent []byte
  18. perMille []byte
  19. timeSeparator []byte
  20. inifinity []byte
  21. currencies [][]byte // idx = enum of currency code
  22. currencyNegativePrefix []byte
  23. currencyNegativeSuffix []byte
  24. monthsAbbreviated [][]byte
  25. monthsNarrow [][]byte
  26. monthsWide [][]byte
  27. daysAbbreviated [][]byte
  28. daysNarrow [][]byte
  29. daysShort [][]byte
  30. daysWide [][]byte
  31. periodsAbbreviated [][]byte
  32. periodsNarrow [][]byte
  33. periodsShort [][]byte
  34. periodsWide [][]byte
  35. erasAbbreviated [][]byte
  36. erasNarrow [][]byte
  37. erasWide [][]byte
  38. timezones map[string][]byte
  39. }
  40. // New returns a new instance of translator for the 'ms' locale
  41. func New() locales.Translator {
  42. return &ms{
  43. locale: "ms",
  44. pluralsCardinal: []locales.PluralRule{6},
  45. pluralsOrdinal: []locales.PluralRule{2, 6},
  46. pluralsRange: []locales.PluralRule{6},
  47. decimal: []byte{0x2e},
  48. group: []byte{0x2c},
  49. minus: []byte{0x2d},
  50. percent: []byte{0x25},
  51. perMille: []byte{0xe2, 0x80, 0xb0},
  52. timeSeparator: []byte{0x3a},
  53. inifinity: []byte{0xe2, 0x88, 0x9e},
  54. currencies: [][]uint8{{0x41, 0x44, 0x50, 0x20}, {0x41, 0x45, 0x44}, {0x41, 0x46, 0x41, 0x20}, {0x41, 0x46, 0x4e}, {0x41, 0x4c, 0x4b, 0x20}, {0x41, 0x4c, 0x4c}, {0x41, 0x4d, 0x44}, {0x41, 0x4e, 0x47}, {0x41, 0x4f, 0x41}, {0x41, 0x4f, 0x4b, 0x20}, {0x41, 0x4f, 0x4e, 0x20}, {0x41, 0x4f, 0x52, 0x20}, {0x41, 0x52, 0x41, 0x20}, {0x41, 0x52, 0x4c, 0x20}, {0x41, 0x52, 0x4d, 0x20}, {0x41, 0x52, 0x50, 0x20}, {0x41, 0x52, 0x53}, {0x41, 0x54, 0x53, 0x20}, {0x41, 0x24}, {0x41, 0x57, 0x47}, {0x41, 0x5a, 0x4d, 0x20}, {0x41, 0x5a, 0x4e}, {0x42, 0x41, 0x44, 0x20}, {0x42, 0x41, 0x4d}, {0x42, 0x41, 0x4e, 0x20}, {0x42, 0x42, 0x44}, {0x42, 0x44, 0x54}, {0x42, 0x45, 0x43, 0x20}, {0x42, 0x45, 0x46, 0x20}, {0x42, 0x45, 0x4c, 0x20}, {0x42, 0x47, 0x4c, 0x20}, {0x42, 0x47, 0x4d, 0x20}, {0x42, 0x47, 0x4e}, {0x42, 0x47, 0x4f, 0x20}, {0x42, 0x48, 0x44}, {0x42, 0x49, 0x46}, {0x42, 0x4d, 0x44}, {0x42, 0x4e, 0x44}, {0x42, 0x4f, 0x42}, {0x42, 0x4f, 0x4c, 0x20}, {0x42, 0x4f, 0x50, 0x20}, {0x42, 0x4f, 0x56, 0x20}, {0x42, 0x52, 0x42, 0x20}, {0x42, 0x52, 0x43, 0x20}, {0x42, 0x52, 0x45, 0x20}, {0x52, 0x24}, {0x42, 0x52, 0x4e, 0x20}, {0x42, 0x52, 0x52, 0x20}, {0x42, 0x52, 0x5a, 0x20}, {0x42, 0x53, 0x44}, {0x42, 0x54, 0x4e}, {0x42, 0x55, 0x4b, 0x20}, {0x42, 0x57, 0x50}, {0x42, 0x59, 0x42, 0x20}, {0x42, 0x59, 0x52}, {0x42, 0x5a, 0x44}, {0x43, 0x41, 0x44}, {0x43, 0x44, 0x46}, {0x43, 0x48, 0x45, 0x20}, {0x43, 0x48, 0x46}, {0x43, 0x48, 0x57, 0x20}, {0x43, 0x4c, 0x45, 0x20}, {0x43, 0x4c, 0x46, 0x20}, {0x43, 0x4c, 0x50}, {0x43, 0x4e, 0x58, 0x20}, {0x43, 0x4e, 0xc2, 0xa5}, {0x43, 0x4f, 0x50}, {0x43, 0x4f, 0x55, 0x20}, {0x43, 0x52, 0x43}, {0x43, 0x53, 0x44, 0x20}, {0x43, 0x53, 0x4b, 0x20}, {0x43, 0x55, 0x43}, {0x43, 0x55, 0x50}, {0x43, 0x56, 0x45}, {0x43, 0x59, 0x50, 0x20}, {0x43, 0x5a, 0x4b}, {0x44, 0x44, 0x4d, 0x20}, {0x44, 0x45, 0x4d, 0x20}, {0x44, 0x4a, 0x46}, {0x44, 0x4b, 0x4b}, {0x44, 0x4f, 0x50}, {0x44, 0x5a, 0x44}, {0x45, 0x43, 0x53, 0x20}, {0x45, 0x43, 0x56, 0x20}, {0x45, 0x45, 0x4b, 0x20}, {0x45, 0x47, 0x50}, {0x45, 0x52, 0x4e}, {0x45, 0x53, 0x41, 0x20}, {0x45, 0x53, 0x42, 0x20}, {0x45, 0x53, 0x50, 0x20}, {0x45, 0x54, 0x42}, {0xe2, 0x82, 0xac}, {0x46, 0x49, 0x4d, 0x20}, {0x46, 0x4a, 0x44}, {0x46, 0x4b, 0x50}, {0x46, 0x52, 0x46, 0x20}, {0xc2, 0xa3}, {0x47, 0x45, 0x4b, 0x20}, {0x47, 0x45, 0x4c}, {0x47, 0x48, 0x43, 0x20}, {0x47, 0x48, 0x53}, {0x47, 0x49, 0x50}, {0x47, 0x4d, 0x44}, {0x47, 0x4e, 0x46}, {0x47, 0x4e, 0x53, 0x20}, {0x47, 0x51, 0x45, 0x20}, {0x47, 0x52, 0x44, 0x20}, {0x47, 0x54, 0x51}, {0x47, 0x57, 0x45, 0x20}, {0x47, 0x57, 0x50, 0x20}, {0x47, 0x59, 0x44}, {0x48, 0x4b, 0x24}, {0x48, 0x4e, 0x4c}, {0x48, 0x52, 0x44, 0x20}, {0x48, 0x52, 0x4b}, {0x48, 0x54, 0x47}, {0x48, 0x55, 0x46}, {0x49, 0x44, 0x52}, {0x49, 0x45, 0x50, 0x20}, {0x49, 0x4c, 0x50, 0x20}, {0x49, 0x4c, 0x52, 0x20}, {0xe2, 0x82, 0xaa}, {0xe2, 0x82, 0xb9}, {0x49, 0x51, 0x44}, {0x49, 0x52, 0x52}, {0x49, 0x53, 0x4a, 0x20}, {0x49, 0x53, 0x4b}, {0x49, 0x54, 0x4c, 0x20}, {0x4a, 0x4d, 0x44}, {0x4a, 0x4f, 0x44}, {0x4a, 0x50, 0xc2, 0xa5}, {0x4b, 0x45, 0x53}, {0x4b, 0x47, 0x53}, {0x4b, 0x48, 0x52}, {0x4b, 0x4d, 0x46}, {0x4b, 0x50, 0x57}, {0x4b, 0x52, 0x48, 0x20}, {0x4b, 0x52, 0x4f, 0x20}, {0xe2, 0x82, 0xa9}, {0x4b, 0x57, 0x44}, {0x4b, 0x59, 0x44}, {0x4b, 0x5a, 0x54}, {0x4c, 0x41, 0x4b}, {0x4c, 0x42, 0x50}, {0x4c, 0x4b, 0x52}, {0x4c, 0x52, 0x44}, {0x4c, 0x53, 0x4c, 0x20}, {0x4c, 0x54, 0x4c}, {0x4c, 0x54, 0x54, 0x20}, {0x4c, 0x55, 0x43, 0x20}, {0x4c, 0x55, 0x46, 0x20}, {0x4c, 0x55, 0x4c, 0x20}, {0x4c, 0x56, 0x4c}, {0x4c, 0x56, 0x52, 0x20}, {0x4c, 0x59, 0x44}, {0x4d, 0x41, 0x44}, {0x4d, 0x41, 0x46, 0x20}, {0x4d, 0x43, 0x46, 0x20}, {0x4d, 0x44, 0x43, 0x20}, {0x4d, 0x44, 0x4c}, {0x4d, 0x47, 0x41}, {0x4d, 0x47, 0x46, 0x20}, {0x4d, 0x4b, 0x44}, {0x4d, 0x4b, 0x4e, 0x20}, {0x4d, 0x4c, 0x46, 0x20}, {0x4d, 0x4d, 0x4b}, {0x4d, 0x4e, 0x54}, {0x4d, 0x4f, 0x50}, {0x4d, 0x52, 0x4f}, {0x4d, 0x54, 0x4c, 0x20}, {0x4d, 0x54, 0x50, 0x20}, {0x4d, 0x55, 0x52}, {0x4d, 0x56, 0x50, 0x20}, {0x4d, 0x56, 0x52}, {0x4d, 0x57, 0x4b}, {0x4d, 0x58, 0x4e}, {0x4d, 0x58, 0x50, 0x20}, {0x4d, 0x58, 0x56, 0x20}, {0x52, 0x4d}, {0x4d, 0x5a, 0x45, 0x20}, {0x4d, 0x5a, 0x4d, 0x20}, {0x4d, 0x5a, 0x4e}, {0x4e, 0x41, 0x44}, {0x4e, 0x47, 0x4e}, {0x4e, 0x49, 0x43, 0x20}, {0x4e, 0x49, 0x4f}, {0x4e, 0x4c, 0x47, 0x20}, {0x4e, 0x4f, 0x4b}, {0x4e, 0x50, 0x52}, {0x4e, 0x5a, 0x24}, {0x4f, 0x4d, 0x52}, {0x50, 0x41, 0x42}, {0x50, 0x45, 0x49, 0x20}, {0x50, 0x45, 0x4e}, {0x50, 0x45, 0x53, 0x20}, {0x50, 0x47, 0x4b}, {0x50, 0x48, 0x50}, {0x50, 0x4b, 0x52}, {0x50, 0x4c, 0x4e}, {0x50, 0x4c, 0x5a, 0x20}, {0x50, 0x54, 0x45, 0x20}, {0x50, 0x59, 0x47}, {0x51, 0x41, 0x52}, {0x52, 0x48, 0x44, 0x20}, {0x52, 0x4f, 0x4c, 0x20}, {0x52, 0x4f, 0x4e}, {0x52, 0x53, 0x44}, {0x52, 0x55, 0x42}, {0x52, 0x55, 0x52, 0x20}, {0x52, 0x57, 0x46}, {0x53, 0x41, 0x52}, {0x53, 0x42, 0x44}, {0x53, 0x43, 0x52}, {0x53, 0x44, 0x44, 0x20}, {0x53, 0x44, 0x47}, {0x53, 0x44, 0x50, 0x20}, {0x53, 0x45, 0x4b}, {0x53, 0x47, 0x44}, {0x53, 0x48, 0x50}, {0x53, 0x49, 0x54, 0x20}, {0x53, 0x4b, 0x4b, 0x20}, {0x53, 0x4c, 0x4c}, {0x53, 0x4f, 0x53}, {0x53, 0x52, 0x44}, {0x53, 0x52, 0x47, 0x20}, {0x53, 0x53, 0x50}, {0x53, 0x54, 0x44}, {0x53, 0x55, 0x52, 0x20}, {0x53, 0x56, 0x43, 0x20}, {0x53, 0x59, 0x50}, {0x53, 0x5a, 0x4c}, {0x54, 0x48, 0x42}, {0x54, 0x4a, 0x52, 0x20}, {0x54, 0x4a, 0x53}, {0x54, 0x4d, 0x4d, 0x20}, {0x54, 0x4d, 0x54}, {0x54, 0x4e, 0x44}, {0x54, 0x4f, 0x50}, {0x54, 0x50, 0x45, 0x20}, {0x54, 0x52, 0x4c, 0x20}, {0x54, 0x52, 0x59}, {0x54, 0x54, 0x44}, {0x4e, 0x54, 0x24}, {0x54, 0x5a, 0x53}, {0x55, 0x41, 0x48}, {0x55, 0x41, 0x4b, 0x20}, {0x55, 0x47, 0x53, 0x20}, {0x55, 0x47, 0x58}, {0x55, 0x53, 0x44}, {0x55, 0x53, 0x4e, 0x20}, {0x55, 0x53, 0x53, 0x20}, {0x55, 0x59, 0x49, 0x20}, {0x55, 0x59, 0x50, 0x20}, {0x55, 0x59, 0x55}, {0x55, 0x5a, 0x53}, {0x56, 0x45, 0x42, 0x20}, {0x56, 0x45, 0x46}, {0xe2, 0x82, 0xab}, {0x56, 0x4e, 0x4e, 0x20}, {0x56, 0x55, 0x56}, {0x57, 0x53, 0x54}, {0x46, 0x43, 0x46, 0x41}, {0x58, 0x41, 0x47, 0x20}, {0x58, 0x41, 0x55, 0x20}, {0x58, 0x42, 0x41, 0x20}, {0x58, 0x42, 0x42, 0x20}, {0x58, 0x42, 0x43, 0x20}, {0x58, 0x42, 0x44, 0x20}, {0x45, 0x43, 0x24}, {0x58, 0x44, 0x52, 0x20}, {0x58, 0x45, 0x55, 0x20}, {0x58, 0x46, 0x4f, 0x20}, {0x58, 0x46, 0x55, 0x20}, {0x43, 0x46, 0x41}, {0x58, 0x50, 0x44, 0x20}, {0x43, 0x46, 0x50, 0x46}, {0x58, 0x50, 0x54, 0x20}, {0x58, 0x52, 0x45, 0x20}, {0x58, 0x53, 0x55, 0x20}, {0x58, 0x54, 0x53, 0x20}, {0x58, 0x55, 0x41, 0x20}, {0x58, 0x58, 0x58, 0x20}, {0x59, 0x44, 0x44, 0x20}, {0x59, 0x45, 0x52}, {0x59, 0x55, 0x44, 0x20}, {0x59, 0x55, 0x4d, 0x20}, {0x59, 0x55, 0x4e, 0x20}, {0x59, 0x55, 0x52, 0x20}, {0x5a, 0x41, 0x4c, 0x20}, {0x5a, 0x41, 0x52}, {0x5a, 0x4d, 0x4b}, {0x5a, 0x4d, 0x57}, {0x5a, 0x52, 0x4e, 0x20}, {0x5a, 0x52, 0x5a, 0x20}, {0x5a, 0x57, 0x44, 0x20}, {0x5a, 0x57, 0x4c, 0x20}, {0x5a, 0x57, 0x52, 0x20}},
  55. currencyNegativePrefix: []byte{0x28},
  56. currencyNegativeSuffix: []byte{0x29},
  57. monthsAbbreviated: [][]uint8{[]uint8(nil), {0x4a, 0x61, 0x6e}, {0x46, 0x65, 0x62}, {0x4d, 0x61, 0x63}, {0x41, 0x70, 0x72}, {0x4d, 0x65, 0x69}, {0x4a, 0x75, 0x6e}, {0x4a, 0x75, 0x6c}, {0x4f, 0x67, 0x6f}, {0x53, 0x65, 0x70}, {0x4f, 0x6b, 0x74}, {0x4e, 0x6f, 0x76}, {0x44, 0x69, 0x73}},
  58. monthsNarrow: [][]uint8{[]uint8(nil), {0x4a}, {0x46}, {0x4d}, {0x41}, {0x4d}, {0x4a}, {0x4a}, {0x4f}, {0x53}, {0x4f}, {0x4e}, {0x44}},
  59. monthsWide: [][]uint8{[]uint8(nil), {0x4a, 0x61, 0x6e, 0x75, 0x61, 0x72, 0x69}, {0x46, 0x65, 0x62, 0x72, 0x75, 0x61, 0x72, 0x69}, {0x4d, 0x61, 0x63}, {0x41, 0x70, 0x72, 0x69, 0x6c}, {0x4d, 0x65, 0x69}, {0x4a, 0x75, 0x6e}, {0x4a, 0x75, 0x6c, 0x61, 0x69}, {0x4f, 0x67, 0x6f, 0x73}, {0x53, 0x65, 0x70, 0x74, 0x65, 0x6d, 0x62, 0x65, 0x72}, {0x4f, 0x6b, 0x74, 0x6f, 0x62, 0x65, 0x72}, {0x4e, 0x6f, 0x76, 0x65, 0x6d, 0x62, 0x65, 0x72}, {0x44, 0x69, 0x73, 0x65, 0x6d, 0x62, 0x65, 0x72}},
  60. daysAbbreviated: [][]uint8{{0x41, 0x68, 0x64}, {0x49, 0x73, 0x6e}, {0x53, 0x65, 0x6c}, {0x52, 0x61, 0x62}, {0x4b, 0x68, 0x61}, {0x4a, 0x75, 0x6d}, {0x53, 0x61, 0x62}},
  61. daysNarrow: [][]uint8{{0x41}, {0x49}, {0x53}, {0x52}, {0x4b}, {0x4a}, {0x53}},
  62. daysShort: [][]uint8{{0x41, 0x68}, {0x49, 0x73}, {0x53, 0x65}, {0x52, 0x61}, {0x4b, 0x68}, {0x4a, 0x75}, {0x53, 0x61}},
  63. daysWide: [][]uint8{{0x41, 0x68, 0x61, 0x64}, {0x49, 0x73, 0x6e, 0x69, 0x6e}, {0x53, 0x65, 0x6c, 0x61, 0x73, 0x61}, {0x52, 0x61, 0x62, 0x75}, {0x4b, 0x68, 0x61, 0x6d, 0x69, 0x73}, {0x4a, 0x75, 0x6d, 0x61, 0x61, 0x74}, {0x53, 0x61, 0x62, 0x74, 0x75}},
  64. periodsAbbreviated: [][]uint8{{0x50, 0x47}, {0x50, 0x54, 0x47}},
  65. periodsNarrow: [][]uint8{{0x61}, {0x70}},
  66. periodsWide: [][]uint8{{0x50, 0x47}, {0x50, 0x54, 0x47}},
  67. erasAbbreviated: [][]uint8{{0x53, 0x2e, 0x4d, 0x2e}, {0x54, 0x4d}},
  68. erasNarrow: [][]uint8{[]uint8(nil), []uint8(nil)},
  69. erasWide: [][]uint8{{0x53, 0x2e, 0x4d, 0x2e}, {0x54, 0x4d}},
  70. timezones: map[string][]uint8{"COT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x43, 0x6f, 0x6c, 0x6f, 0x6d, 0x62, 0x69, 0x61}, "CLT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x43, 0x68, 0x69, 0x6c, 0x65}, "AKDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x41, 0x6c, 0x61, 0x73, 0x6b, 0x61}, "WART": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x69, 0x6e, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "VET": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x56, 0x65, 0x6e, 0x65, 0x7a, 0x75, 0x65, 0x6c, 0x61}, "AEDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "MEZ": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x45, 0x72, 0x6f, 0x70, 0x61, 0x68, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "PST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x50, 0x61, 0x73, 0x69, 0x66, 0x69, 0x6b}, "JST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x4a, 0x65, 0x70, 0x75, 0x6e}, "WARST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x41, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x69, 0x6e, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "WIB": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x49, 0x6e, 0x64, 0x6f, 0x6e, 0x65, 0x73, 0x69, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "GYT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x47, 0x75, 0x79, 0x61, 0x6e, 0x61}, "ADT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x41, 0x74, 0x6c, 0x61, 0x6e, 0x74, 0x69, 0x6b}, "EDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "LHDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x4c, 0x6f, 0x72, 0x64, 0x20, 0x48, 0x6f, 0x77, 0x65}, "ARST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x41, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x69, 0x6e, 0x61}, "OEZ": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x45, 0x72, 0x6f, 0x70, 0x61, 0x68, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "HAT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x4e, 0x65, 0x77, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x6c, 0x61, 0x6e, 0x64}, "WAST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "SGT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x53, 0x69, 0x6e, 0x67, 0x61, 0x70, 0x75, 0x72, 0x61}, "PDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x50, 0x61, 0x73, 0x69, 0x66, 0x69, 0x6b}, "UYST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x55, 0x72, 0x75, 0x67, 0x75, 0x61, 0x79}, "ChST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x43, 0x68, 0x61, 0x6d, 0x6f, 0x72, 0x72, 0x6f}, "CAT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "TMT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x54, 0x75, 0x72, 0x6b, 0x6d, 0x65, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x6e}, "ACWST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61}, "AWST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "SAST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x20, 0x53, 0x65, 0x6c, 0x61, 0x74, 0x61, 0x6e}, "WESZ": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x45, 0x72, 0x6f, 0x70, 0x61, 0x68, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "LHST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x4c, 0x6f, 0x72, 0x64, 0x20, 0x48, 0x6f, 0x77, 0x65}, "BT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x42, 0x68, 0x75, 0x74, 0x61, 0x6e}, "HADT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x48, 0x61, 0x77, 0x61, 0x69, 0x69, 0x2d, 0x41, 0x6c, 0x65, 0x75, 0x74, 0x69, 0x61, 0x6e}, "AEST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61}, "CHAST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x43, 0x68, 0x61, 0x74, 0x68, 0x61, 0x6d}, "TMST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x54, 0x75, 0x72, 0x6b, 0x6d, 0x65, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x6e}, "JDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x4a, 0x65, 0x70, 0x75, 0x6e}, "AWDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "HKT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x48, 0x6f, 0x6e, 0x67, 0x20, 0x4b, 0x6f, 0x6e, 0x67}, "ACST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "OESZ": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x45, 0x72, 0x6f, 0x70, 0x61, 0x68, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "EST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "ECT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x45, 0x63, 0x75, 0x61, 0x64, 0x6f, 0x72}, "MST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x50, 0x65, 0x72, 0x67, 0x75, 0x6e, 0x75, 0x6e, 0x67, 0x61, 0x6e}, "∅∅∅": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x50, 0x65, 0x72, 0x75}, "CST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x50, 0x75, 0x73, 0x61, 0x74}, "MESZ": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x45, 0x72, 0x6f, 0x70, 0x61, 0x68, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "BOT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x42, 0x6f, 0x6c, 0x69, 0x76, 0x69, 0x61}, "WAT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}, "IST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x49, 0x6e, 0x64, 0x69, 0x61}, "ACDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "COST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x43, 0x6f, 0x6c, 0x6f, 0x6d, 0x62, 0x69, 0x61}, "GFT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x47, 0x75, 0x79, 0x61, 0x6e, 0x61, 0x20, 0x50, 0x65, 0x72, 0x61, 0x6e, 0x63, 0x69, 0x73}, "NZDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x4e, 0x65, 0x77, 0x20, 0x5a, 0x65, 0x61, 0x6c, 0x61, 0x6e, 0x64}, "CDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "HAST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x48, 0x61, 0x77, 0x61, 0x69, 0x69, 0x2d, 0x41, 0x6c, 0x65, 0x75, 0x74, 0x69, 0x61, 0x6e}, "GMT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x69, 0x6e, 0x20, 0x47, 0x72, 0x65, 0x65, 0x6e, 0x77, 0x69, 0x63, 0x68}, "AKST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x6c, 0x61, 0x73, 0x6b, 0x61}, "UYT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x55, 0x72, 0x75, 0x67, 0x75, 0x61, 0x79}, "MDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x48, 0x61, 0x72, 0x69, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x50, 0x65, 0x72, 0x67, 0x75, 0x6e, 0x75, 0x6e, 0x67, 0x61, 0x6e}, "NZST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x4e, 0x65, 0x77, 0x20, 0x5a, 0x65, 0x61, 0x6c, 0x61, 0x6e, 0x64}, "MYT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x61, 0x6c, 0x61, 0x79, 0x73, 0x69, 0x61}, "CHADT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x43, 0x68, 0x61, 0x74, 0x68, 0x61, 0x6d}, "AST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x74, 0x6c, 0x61, 0x6e, 0x74, 0x69, 0x6b}, "WIT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x49, 0x6e, 0x64, 0x6f, 0x6e, 0x65, 0x73, 0x69, 0x61, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "ACWDT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x69, 0x61, 0x6e, 0x67, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68, 0x20, 0x41, 0x75, 0x73, 0x74, 0x72, 0x61, 0x6c, 0x69, 0x61}, "HKST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x48, 0x6f, 0x6e, 0x67, 0x20, 0x4b, 0x6f, 0x6e, 0x67}, "SRT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x53, 0x75, 0x72, 0x69, 0x6e, 0x61, 0x6d, 0x65}, "WITA": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x49, 0x6e, 0x64, 0x6f, 0x6e, 0x65, 0x73, 0x69, 0x61, 0x20, 0x54, 0x65, 0x6e, 0x67, 0x61, 0x68}, "EAT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x41, 0x66, 0x72, 0x69, 0x6b, 0x61, 0x20, 0x54, 0x69, 0x6d, 0x75, 0x72}, "ART": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x41, 0x72, 0x67, 0x65, 0x6e, 0x74, 0x69, 0x6e, 0x61}, "CLST": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x4d, 0x75, 0x73, 0x69, 0x6d, 0x20, 0x50, 0x61, 0x6e, 0x61, 0x73, 0x20, 0x43, 0x68, 0x69, 0x6c, 0x65}, "HNT": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x4e, 0x65, 0x77, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x6c, 0x61, 0x6e, 0x64}, "WEZ": {0x57, 0x61, 0x6b, 0x74, 0x75, 0x20, 0x50, 0x69, 0x61, 0x77, 0x61, 0x69, 0x20, 0x45, 0x72, 0x6f, 0x70, 0x61, 0x68, 0x20, 0x42, 0x61, 0x72, 0x61, 0x74}},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (ms *ms) Locale() string {
  75. return ms.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'ms'
  78. func (ms *ms) PluralsCardinal() []locales.PluralRule {
  79. return ms.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ms'
  82. func (ms *ms) PluralsOrdinal() []locales.PluralRule {
  83. return ms.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'ms'
  86. func (ms *ms) PluralsRange() []locales.PluralRule {
  87. return ms.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ms'
  90. func (ms *ms) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. return locales.PluralRuleOther
  92. }
  93. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ms'
  94. func (ms *ms) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  95. n := math.Abs(num)
  96. if n == 1 {
  97. return locales.PluralRuleOne
  98. }
  99. return locales.PluralRuleOther
  100. }
  101. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ms'
  102. func (ms *ms) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  103. return locales.PluralRuleOther
  104. }
  105. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  106. func (ms *ms) MonthAbbreviated(month time.Month) []byte {
  107. return ms.monthsAbbreviated[month]
  108. }
  109. // MonthsAbbreviated returns the locales abbreviated months
  110. func (ms *ms) MonthsAbbreviated() [][]byte {
  111. return ms.monthsAbbreviated[1:]
  112. }
  113. // MonthNarrow returns the locales narrow month given the 'month' provided
  114. func (ms *ms) MonthNarrow(month time.Month) []byte {
  115. return ms.monthsNarrow[month]
  116. }
  117. // MonthsNarrow returns the locales narrow months
  118. func (ms *ms) MonthsNarrow() [][]byte {
  119. return ms.monthsNarrow[1:]
  120. }
  121. // MonthWide returns the locales wide month given the 'month' provided
  122. func (ms *ms) MonthWide(month time.Month) []byte {
  123. return ms.monthsWide[month]
  124. }
  125. // MonthsWide returns the locales wide months
  126. func (ms *ms) MonthsWide() [][]byte {
  127. return ms.monthsWide[1:]
  128. }
  129. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  130. func (ms *ms) WeekdayAbbreviated(weekday time.Weekday) []byte {
  131. return ms.daysAbbreviated[weekday]
  132. }
  133. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  134. func (ms *ms) WeekdaysAbbreviated() [][]byte {
  135. return ms.daysAbbreviated
  136. }
  137. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  138. func (ms *ms) WeekdayNarrow(weekday time.Weekday) []byte {
  139. return ms.daysNarrow[weekday]
  140. }
  141. // WeekdaysNarrow returns the locales narrow weekdays
  142. func (ms *ms) WeekdaysNarrow() [][]byte {
  143. return ms.daysNarrow
  144. }
  145. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  146. func (ms *ms) WeekdayShort(weekday time.Weekday) []byte {
  147. return ms.daysShort[weekday]
  148. }
  149. // WeekdaysShort returns the locales short weekdays
  150. func (ms *ms) WeekdaysShort() [][]byte {
  151. return ms.daysShort
  152. }
  153. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  154. func (ms *ms) WeekdayWide(weekday time.Weekday) []byte {
  155. return ms.daysWide[weekday]
  156. }
  157. // WeekdaysWide returns the locales wide weekdays
  158. func (ms *ms) WeekdaysWide() [][]byte {
  159. return ms.daysWide
  160. }
  161. // FmtNumber returns 'num' with digits/precision of 'v' for 'ms' and handles both Whole and Real numbers based on 'v'
  162. // returned as a []byte just in case the caller wishes to add more and can help
  163. // avoid allocations; otherwise just cast as string.
  164. func (ms *ms) FmtNumber(num float64, v uint64) []byte {
  165. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  166. l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
  167. count := 0
  168. inWhole := v == 0
  169. b := make([]byte, 0, l)
  170. for i := len(s) - 1; i >= 0; i-- {
  171. if s[i] == '.' {
  172. b = append(b, ms.decimal[0])
  173. inWhole = true
  174. continue
  175. }
  176. if inWhole {
  177. if count == 3 {
  178. b = append(b, ms.group[0])
  179. count = 1
  180. } else {
  181. count++
  182. }
  183. }
  184. b = append(b, s[i])
  185. }
  186. if num < 0 {
  187. b = append(b, ms.minus[0])
  188. }
  189. // reverse
  190. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  191. b[i], b[j] = b[j], b[i]
  192. }
  193. return b
  194. }
  195. // FmtPercent returns 'num' with digits/precision of 'v' for 'ms' and handles both Whole and Real numbers based on 'v'
  196. // returned as a []byte just in case the caller wishes to add more and can help
  197. // avoid allocations; otherwise just cast as string.
  198. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  199. func (ms *ms) FmtPercent(num float64, v uint64) []byte {
  200. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  201. l := len(s) + len(ms.decimal)
  202. b := make([]byte, 0, l)
  203. for i := len(s) - 1; i >= 0; i-- {
  204. if s[i] == '.' {
  205. b = append(b, ms.decimal[0])
  206. continue
  207. }
  208. b = append(b, s[i])
  209. }
  210. if num < 0 {
  211. b = append(b, ms.minus[0])
  212. }
  213. // reverse
  214. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  215. b[i], b[j] = b[j], b[i]
  216. }
  217. b = append(b, ms.percent...)
  218. return b
  219. }
  220. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ms'
  221. // returned as a []byte just in case the caller wishes to add more and can help
  222. // avoid allocations; otherwise just cast as string.
  223. func (ms *ms) FmtCurrency(num float64, v uint64, currency currency.Type) []byte {
  224. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  225. symbol := ms.currencies[currency]
  226. l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
  227. count := 0
  228. inWhole := v == 0
  229. b := make([]byte, 0, l)
  230. for i := len(s) - 1; i >= 0; i-- {
  231. if s[i] == '.' {
  232. b = append(b, ms.decimal[0])
  233. inWhole = true
  234. continue
  235. }
  236. if inWhole {
  237. if count == 3 {
  238. b = append(b, ms.group[0])
  239. count = 1
  240. } else {
  241. count++
  242. }
  243. }
  244. b = append(b, s[i])
  245. }
  246. for j := len(symbol) - 1; j >= 0; j-- {
  247. b = append(b, symbol[j])
  248. }
  249. if num < 0 {
  250. b = append(b, ms.minus[0])
  251. }
  252. // reverse
  253. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  254. b[i], b[j] = b[j], b[i]
  255. }
  256. if int(v) < 2 {
  257. if v == 0 {
  258. b = append(b, ms.decimal...)
  259. }
  260. for i := 0; i < 2-int(v); i++ {
  261. b = append(b, '0')
  262. }
  263. }
  264. return b
  265. }
  266. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ms'
  267. // in accounting notation. returned as a []byte just in case the caller wishes to add more and can help
  268. // avoid allocations; otherwise just cast as string.
  269. func (ms *ms) FmtAccounting(num float64, v uint64, currency currency.Type) []byte {
  270. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  271. symbol := ms.currencies[currency]
  272. l := len(s) + len(ms.decimal) + len(ms.group)*len(s[:len(s)-int(v)-1])/3
  273. count := 0
  274. inWhole := v == 0
  275. b := make([]byte, 0, l)
  276. for i := len(s) - 1; i >= 0; i-- {
  277. if s[i] == '.' {
  278. b = append(b, ms.decimal[0])
  279. inWhole = true
  280. continue
  281. }
  282. if inWhole {
  283. if count == 3 {
  284. b = append(b, ms.group[0])
  285. count = 1
  286. } else {
  287. count++
  288. }
  289. }
  290. b = append(b, s[i])
  291. }
  292. if num < 0 {
  293. for j := len(symbol) - 1; j >= 0; j-- {
  294. b = append(b, symbol[j])
  295. }
  296. for j := len(ms.currencyNegativePrefix) - 1; j >= 0; j-- {
  297. b = append(b, ms.currencyNegativePrefix[j])
  298. }
  299. } else {
  300. for j := len(symbol) - 1; j >= 0; j-- {
  301. b = append(b, symbol[j])
  302. }
  303. }
  304. // reverse
  305. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  306. b[i], b[j] = b[j], b[i]
  307. }
  308. if int(v) < 2 {
  309. if v == 0 {
  310. b = append(b, ms.decimal...)
  311. }
  312. for i := 0; i < 2-int(v); i++ {
  313. b = append(b, '0')
  314. }
  315. }
  316. if num < 0 {
  317. b = append(b, ms.currencyNegativeSuffix...)
  318. }
  319. return b
  320. }
  321. // FmtDateShort returns the short date representation of 't' for 'ms'
  322. // returned as a []byte just in case the caller wishes to add more and can help
  323. // avoid allocations; otherwise just cast as string.
  324. func (ms *ms) FmtDateShort(t time.Time) []byte {
  325. b := make([]byte, 0, 32)
  326. b = strconv.AppendInt(b, int64(t.Day()), 10)
  327. b = append(b, []byte{0x2f}...)
  328. if t.Month() < 10 {
  329. b = append(b, '0')
  330. }
  331. b = strconv.AppendInt(b, int64(t.Month()), 10)
  332. b = append(b, []byte{0x2f}...)
  333. if t.Year() > 9 {
  334. b = append(b, strconv.Itoa(t.Year())[2:]...)
  335. } else {
  336. b = append(b, strconv.Itoa(t.Year())[1:]...)
  337. }
  338. return b
  339. }
  340. // FmtDateMedium returns the medium date representation of 't' for 'ms'
  341. // returned as a []byte just in case the caller wishes to add more and can help
  342. // avoid allocations; otherwise just cast as string.
  343. func (ms *ms) FmtDateMedium(t time.Time) []byte {
  344. b := make([]byte, 0, 32)
  345. b = strconv.AppendInt(b, int64(t.Day()), 10)
  346. b = append(b, []byte{0x20}...)
  347. b = append(b, ms.monthsAbbreviated[t.Month()]...)
  348. b = append(b, []byte{0x20}...)
  349. b = strconv.AppendInt(b, int64(t.Year()), 10)
  350. return b
  351. }
  352. // FmtDateLong returns the long date representation of 't' for 'ms'
  353. // returned as a []byte just in case the caller wishes to add more and can help
  354. // avoid allocations; otherwise just cast as string.
  355. func (ms *ms) FmtDateLong(t time.Time) []byte {
  356. b := make([]byte, 0, 32)
  357. b = strconv.AppendInt(b, int64(t.Day()), 10)
  358. b = append(b, []byte{0x20}...)
  359. b = append(b, ms.monthsWide[t.Month()]...)
  360. b = append(b, []byte{0x20}...)
  361. b = strconv.AppendInt(b, int64(t.Year()), 10)
  362. return b
  363. }
  364. // FmtDateFull returns the full date representation of 't' for 'ms'
  365. // returned as a []byte just in case the caller wishes to add more and can help
  366. // avoid allocations; otherwise just cast as string.
  367. func (ms *ms) FmtDateFull(t time.Time) []byte {
  368. b := make([]byte, 0, 32)
  369. b = append(b, ms.daysWide[t.Weekday()]...)
  370. b = append(b, []byte{0x2c, 0x20}...)
  371. b = strconv.AppendInt(b, int64(t.Day()), 10)
  372. b = append(b, []byte{0x20}...)
  373. b = append(b, ms.monthsWide[t.Month()]...)
  374. b = append(b, []byte{0x20}...)
  375. b = strconv.AppendInt(b, int64(t.Year()), 10)
  376. return b
  377. }
  378. // FmtTimeShort returns the short time representation of 't' for 'ms'
  379. // returned as a []byte just in case the caller wishes to add more and can help
  380. // avoid allocations; otherwise just cast as string.
  381. func (ms *ms) FmtTimeShort(t time.Time) []byte {
  382. b := make([]byte, 0, 32)
  383. h := t.Hour()
  384. if h > 12 {
  385. h -= 12
  386. }
  387. b = strconv.AppendInt(b, int64(h), 10)
  388. b = append(b, ms.timeSeparator...)
  389. if t.Minute() < 10 {
  390. b = append(b, '0')
  391. }
  392. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  393. b = append(b, []byte{0x20}...)
  394. if t.Hour() < 12 {
  395. b = append(b, ms.periodsAbbreviated[0]...)
  396. } else {
  397. b = append(b, ms.periodsAbbreviated[1]...)
  398. }
  399. return b
  400. }
  401. // FmtTimeMedium returns the medium time representation of 't' for 'ms'
  402. // returned as a []byte just in case the caller wishes to add more and can help
  403. // avoid allocations; otherwise just cast as string.
  404. func (ms *ms) FmtTimeMedium(t time.Time) []byte {
  405. b := make([]byte, 0, 32)
  406. h := t.Hour()
  407. if h > 12 {
  408. h -= 12
  409. }
  410. b = strconv.AppendInt(b, int64(h), 10)
  411. b = append(b, ms.timeSeparator...)
  412. if t.Minute() < 10 {
  413. b = append(b, '0')
  414. }
  415. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  416. b = append(b, ms.timeSeparator...)
  417. if t.Second() < 10 {
  418. b = append(b, '0')
  419. }
  420. b = strconv.AppendInt(b, int64(t.Second()), 10)
  421. b = append(b, []byte{0x20}...)
  422. if t.Hour() < 12 {
  423. b = append(b, ms.periodsAbbreviated[0]...)
  424. } else {
  425. b = append(b, ms.periodsAbbreviated[1]...)
  426. }
  427. return b
  428. }
  429. // FmtTimeLong returns the long time representation of 't' for 'ms'
  430. // returned as a []byte just in case the caller wishes to add more and can help
  431. // avoid allocations; otherwise just cast as string.
  432. func (ms *ms) FmtTimeLong(t time.Time) []byte {
  433. b := make([]byte, 0, 32)
  434. h := t.Hour()
  435. if h > 12 {
  436. h -= 12
  437. }
  438. b = strconv.AppendInt(b, int64(h), 10)
  439. b = append(b, ms.timeSeparator...)
  440. if t.Minute() < 10 {
  441. b = append(b, '0')
  442. }
  443. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  444. b = append(b, ms.timeSeparator...)
  445. if t.Second() < 10 {
  446. b = append(b, '0')
  447. }
  448. b = strconv.AppendInt(b, int64(t.Second()), 10)
  449. b = append(b, []byte{0x20}...)
  450. if t.Hour() < 12 {
  451. b = append(b, ms.periodsAbbreviated[0]...)
  452. } else {
  453. b = append(b, ms.periodsAbbreviated[1]...)
  454. }
  455. b = append(b, []byte{0x20}...)
  456. tz, _ := t.Zone()
  457. b = append(b, tz...)
  458. return b
  459. }
  460. // FmtTimeFull returns the full time representation of 't' for 'ms'
  461. // returned as a []byte just in case the caller wishes to add more and can help
  462. // avoid allocations; otherwise just cast as string.
  463. func (ms *ms) FmtTimeFull(t time.Time) []byte {
  464. b := make([]byte, 0, 32)
  465. h := t.Hour()
  466. if h > 12 {
  467. h -= 12
  468. }
  469. b = strconv.AppendInt(b, int64(h), 10)
  470. b = append(b, ms.timeSeparator...)
  471. if t.Minute() < 10 {
  472. b = append(b, '0')
  473. }
  474. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  475. b = append(b, ms.timeSeparator...)
  476. if t.Second() < 10 {
  477. b = append(b, '0')
  478. }
  479. b = strconv.AppendInt(b, int64(t.Second()), 10)
  480. b = append(b, []byte{0x20}...)
  481. if t.Hour() < 12 {
  482. b = append(b, ms.periodsAbbreviated[0]...)
  483. } else {
  484. b = append(b, ms.periodsAbbreviated[1]...)
  485. }
  486. b = append(b, []byte{0x20}...)
  487. tz, _ := t.Zone()
  488. if btz, ok := ms.timezones[tz]; ok {
  489. b = append(b, btz...)
  490. } else {
  491. b = append(b, tz...)
  492. }
  493. return b
  494. }