en_SS.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. package en_SS
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type en_SS struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal string
  15. group string
  16. minus string
  17. percent string
  18. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyNegativePrefix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'en_SS' locale
  41. func New() locales.Translator {
  42. return &en_SS{
  43. locale: "en_SS",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{2, 3, 4, 6},
  46. pluralsRange: []locales.PluralRule{6},
  47. decimal: ".",
  48. group: ",",
  49. minus: "-",
  50. percent: "%",
  51. perMille: "‰",
  52. timeSeparator: ":",
  53. inifinity: "∞",
  54. currencies: []string{"ADP ", "AED ", "AFA ", "AFN ", "ALK ", "ALL ", "AMD ", "ANG ", "AOA ", "AOK ", "AON ", "AOR ", "ARA ", "ARL ", "ARM ", "ARP ", "ARS ", "ATS ", "AUD ", "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 ", "BRL ", "BRN ", "BRR ", "BRZ ", "BSD ", "BTN ", "BUK ", "BWP ", "BYB ", "BYR ", "BZD ", "CAD ", "CDF ", "CHE ", "CHF ", "CHW ", "CLE ", "CLF ", "CLP ", "CNX ", "CNY ", "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 ", "EUR ", "FIM ", "FJD ", "FKP ", "FRF ", "GB£", "GEK ", "GEL ", "GHC ", "GHS ", "GIP ", "GMD ", "GNF ", "GNS ", "GQE ", "GRD ", "GTQ ", "GWE ", "GWP ", "GYD ", "HKD ", "HNL ", "HRD ", "HRK ", "HTG ", "HUF ", "IDR ", "IEP ", "ILP ", "ILR ", "ILS ", "INR ", "IQD ", "IRR ", "ISJ ", "ISK ", "ITL ", "JMD ", "JOD ", "JPY ", "KES ", "KGS ", "KHR ", "KMF ", "KPW ", "KRH ", "KRO ", "KRW ", "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 ", "MYR ", "MZE ", "MZM ", "MZN ", "NAD ", "NGN ", "NIC ", "NIO ", "NLG ", "NOK ", "NPR ", "NZD ", "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 ", "£", "STD ", "SUR ", "SVC ", "SYP ", "SZL ", "THB ", "TJR ", "TJS ", "TMM ", "TMT ", "TND ", "TOP ", "TPE ", "TRL ", "TRY ", "TTD ", "TWD ", "TZS ", "UAH ", "UAK ", "UGS ", "UGX ", "USD ", "USN ", "USS ", "UYI ", "UYP ", "UYU ", "UZS ", "VEB ", "VEF ", "VND ", "VNN ", "VUV ", "WST ", "XAF ", "XAG ", "XAU ", "XBA ", "XBB ", "XBC ", "XBD ", "XCD ", "XDR ", "XEU ", "XFO ", "XFU ", "XOF ", "XPD ", "XPF ", "XPT ", "XRE ", "XSU ", "XTS ", "XUA ", "XXX ", "YDD ", "YER ", "YUD ", "YUM ", "YUN ", "YUR ", "ZAL ", "ZAR ", "ZMK ", "ZMW ", "ZRN ", "ZRZ ", "ZWD ", "ZWL ", "ZWR "},
  55. currencyNegativePrefix: "(",
  56. currencyNegativeSuffix: ")",
  57. monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
  58. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  59. monthsWide: []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
  60. daysAbbreviated: []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
  61. daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
  62. daysShort: []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"},
  63. daysWide: []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
  64. periodsAbbreviated: []string{"am", "pm"},
  65. periodsNarrow: []string{"a", "p"},
  66. periodsWide: []string{"am", "pm"},
  67. erasAbbreviated: []string{"BC", "AD"},
  68. erasNarrow: []string{"B", "A"},
  69. erasWide: []string{"Before Christ", "Anno Domini"},
  70. timezones: map[string]string{"ACWST": "Australian Central Western Standard Time", "HAST": "Hawaii-Aleutian Standard Time", "HKT": "Hong Kong Standard Time", "BT": "Bhutan Time", "AWDT": "Australian Western Daylight Time", "WAT": "West Africa Standard Time", "OEZ": "Eastern European Standard Time", "TMT": "Turkmenistan Standard Time", "AWST": "Australian Western Standard Time", "CST": "Central Standard Time", "WEZ": "Western European Standard Time", "AEST": "Australian Eastern Standard Time", "HNT": "Newfoundland Standard Time", "WIT": "Eastern Indonesia Time", "OESZ": "Eastern European Summer Time", "ARST": "Argentina Summer Time", "AKST": "Alaska Standard Time", "PDT": "Pacific Daylight Time", "CHADT": "Chatham Daylight Time", "ECT": "Ecuador Time", "HAT": "Newfoundland Daylight Time", "GFT": "French Guiana Time", "IST": "India Standard Time", "WIB": "Western Indonesia Time", "AKDT": "Alaska Daylight Time", "NZDT": "New Zealand Daylight Time", "MST": "Mountain Standard Time", "GMT": "Greenwich Mean Time", "JST": "Japan Standard Time", "SRT": "Suriname Time", "MESZ": "Central European Summer Time", "COT": "Colombia Standard Time", "WART": "Western Argentina Standard Time", "LHST": "Lord Howe Standard Time", "UYT": "Uruguay Standard Time", "CLST": "Chile Summer Time", "EDT": "Eastern Daylight Time", "SAST": "South Africa Standard Time", "LHDT": "Lord Howe Daylight Time", "BOT": "Bolivia Time", "CLT": "Chile Standard Time", "COST": "Colombia Summer Time", "ADT": "Atlantic Daylight Time", "WARST": "Western Argentina Summer Time", "∅∅∅": "Brasilia Summer Time", "MYT": "Malaysia Time", "MEZ": "Central European Standard Time", "TMST": "Turkmenistan Summer Time", "EAT": "East Africa Time", "PST": "Pacific Standard Time", "ChST": "Chamorro Standard Time", "MDT": "Mountain Daylight Time", "CHAST": "Chatham Standard Time", "WESZ": "Western European Summer Time", "AST": "Atlantic Standard Time", "ACST": "Australian Central Standard Time", "GYT": "Guyana Time", "ACWDT": "Australian Central Western Daylight Time", "WAST": "West Africa Summer Time", "ART": "Argentina Standard Time", "NZST": "New Zealand Standard Time", "EST": "Eastern Standard Time", "HADT": "Hawaii-Aleutian Daylight Time", "ACDT": "Australian Central Daylight Time", "VET": "Venezuela Time", "SGT": "Singapore Standard Time", "UYST": "Uruguay Summer Time", "CDT": "Central Daylight Time", "AEDT": "Australian Eastern Daylight Time", "CAT": "Central Africa Time", "HKST": "Hong Kong Summer Time", "WITA": "Central Indonesia Time", "JDT": "Japan Daylight Time"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (en *en_SS) Locale() string {
  75. return en.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'en_SS'
  78. func (en *en_SS) PluralsCardinal() []locales.PluralRule {
  79. return en.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'en_SS'
  82. func (en *en_SS) PluralsOrdinal() []locales.PluralRule {
  83. return en.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'en_SS'
  86. func (en *en_SS) PluralsRange() []locales.PluralRule {
  87. return en.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_SS'
  90. func (en *en_SS) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. i := int64(n)
  93. if i == 1 && v == 0 {
  94. return locales.PluralRuleOne
  95. }
  96. return locales.PluralRuleOther
  97. }
  98. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_SS'
  99. func (en *en_SS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  100. n := math.Abs(num)
  101. nMod10 := math.Mod(n, 10)
  102. nMod100 := math.Mod(n, 100)
  103. if nMod10 == 1 && nMod100 != 11 {
  104. return locales.PluralRuleOne
  105. } else if nMod10 == 2 && nMod100 != 12 {
  106. return locales.PluralRuleTwo
  107. } else if nMod10 == 3 && nMod100 != 13 {
  108. return locales.PluralRuleFew
  109. }
  110. return locales.PluralRuleOther
  111. }
  112. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_SS'
  113. func (en *en_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  114. return locales.PluralRuleOther
  115. }
  116. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  117. func (en *en_SS) MonthAbbreviated(month time.Month) string {
  118. return en.monthsAbbreviated[month]
  119. }
  120. // MonthsAbbreviated returns the locales abbreviated months
  121. func (en *en_SS) MonthsAbbreviated() []string {
  122. return en.monthsAbbreviated[1:]
  123. }
  124. // MonthNarrow returns the locales narrow month given the 'month' provided
  125. func (en *en_SS) MonthNarrow(month time.Month) string {
  126. return en.monthsNarrow[month]
  127. }
  128. // MonthsNarrow returns the locales narrow months
  129. func (en *en_SS) MonthsNarrow() []string {
  130. return en.monthsNarrow[1:]
  131. }
  132. // MonthWide returns the locales wide month given the 'month' provided
  133. func (en *en_SS) MonthWide(month time.Month) string {
  134. return en.monthsWide[month]
  135. }
  136. // MonthsWide returns the locales wide months
  137. func (en *en_SS) MonthsWide() []string {
  138. return en.monthsWide[1:]
  139. }
  140. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  141. func (en *en_SS) WeekdayAbbreviated(weekday time.Weekday) string {
  142. return en.daysAbbreviated[weekday]
  143. }
  144. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  145. func (en *en_SS) WeekdaysAbbreviated() []string {
  146. return en.daysAbbreviated
  147. }
  148. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  149. func (en *en_SS) WeekdayNarrow(weekday time.Weekday) string {
  150. return en.daysNarrow[weekday]
  151. }
  152. // WeekdaysNarrow returns the locales narrow weekdays
  153. func (en *en_SS) WeekdaysNarrow() []string {
  154. return en.daysNarrow
  155. }
  156. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  157. func (en *en_SS) WeekdayShort(weekday time.Weekday) string {
  158. return en.daysShort[weekday]
  159. }
  160. // WeekdaysShort returns the locales short weekdays
  161. func (en *en_SS) WeekdaysShort() []string {
  162. return en.daysShort
  163. }
  164. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  165. func (en *en_SS) WeekdayWide(weekday time.Weekday) string {
  166. return en.daysWide[weekday]
  167. }
  168. // WeekdaysWide returns the locales wide weekdays
  169. func (en *en_SS) WeekdaysWide() []string {
  170. return en.daysWide
  171. }
  172. // FmtNumber returns 'num' with digits/precision of 'v' for 'en_SS' and handles both Whole and Real numbers based on 'v'
  173. func (en *en_SS) FmtNumber(num float64, v uint64) string {
  174. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  175. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  176. count := 0
  177. inWhole := v == 0
  178. b := make([]byte, 0, l)
  179. for i := len(s) - 1; i >= 0; i-- {
  180. if s[i] == '.' {
  181. b = append(b, en.decimal[0])
  182. inWhole = true
  183. continue
  184. }
  185. if inWhole {
  186. if count == 3 {
  187. b = append(b, en.group[0])
  188. count = 1
  189. } else {
  190. count++
  191. }
  192. }
  193. b = append(b, s[i])
  194. }
  195. if num < 0 {
  196. b = append(b, en.minus[0])
  197. }
  198. // reverse
  199. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  200. b[i], b[j] = b[j], b[i]
  201. }
  202. return string(b)
  203. }
  204. // FmtPercent returns 'num' with digits/precision of 'v' for 'en_SS' and handles both Whole and Real numbers based on 'v'
  205. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  206. func (en *en_SS) FmtPercent(num float64, v uint64) string {
  207. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  208. l := len(s) + 3
  209. b := make([]byte, 0, l)
  210. for i := len(s) - 1; i >= 0; i-- {
  211. if s[i] == '.' {
  212. b = append(b, en.decimal[0])
  213. continue
  214. }
  215. b = append(b, s[i])
  216. }
  217. if num < 0 {
  218. b = append(b, en.minus[0])
  219. }
  220. // reverse
  221. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  222. b[i], b[j] = b[j], b[i]
  223. }
  224. b = append(b, en.percent...)
  225. return string(b)
  226. }
  227. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_SS'
  228. func (en *en_SS) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  229. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  230. symbol := en.currencies[currency]
  231. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  232. count := 0
  233. inWhole := v == 0
  234. b := make([]byte, 0, l)
  235. for i := len(s) - 1; i >= 0; i-- {
  236. if s[i] == '.' {
  237. b = append(b, en.decimal[0])
  238. inWhole = true
  239. continue
  240. }
  241. if inWhole {
  242. if count == 3 {
  243. b = append(b, en.group[0])
  244. count = 1
  245. } else {
  246. count++
  247. }
  248. }
  249. b = append(b, s[i])
  250. }
  251. for j := len(symbol) - 1; j >= 0; j-- {
  252. b = append(b, symbol[j])
  253. }
  254. if num < 0 {
  255. b = append(b, en.minus[0])
  256. }
  257. // reverse
  258. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  259. b[i], b[j] = b[j], b[i]
  260. }
  261. if int(v) < 2 {
  262. if v == 0 {
  263. b = append(b, en.decimal...)
  264. }
  265. for i := 0; i < 2-int(v); i++ {
  266. b = append(b, '0')
  267. }
  268. }
  269. return string(b)
  270. }
  271. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_SS'
  272. // in accounting notation.
  273. func (en *en_SS) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  274. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  275. symbol := en.currencies[currency]
  276. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  277. count := 0
  278. inWhole := v == 0
  279. b := make([]byte, 0, l)
  280. for i := len(s) - 1; i >= 0; i-- {
  281. if s[i] == '.' {
  282. b = append(b, en.decimal[0])
  283. inWhole = true
  284. continue
  285. }
  286. if inWhole {
  287. if count == 3 {
  288. b = append(b, en.group[0])
  289. count = 1
  290. } else {
  291. count++
  292. }
  293. }
  294. b = append(b, s[i])
  295. }
  296. if num < 0 {
  297. for j := len(symbol) - 1; j >= 0; j-- {
  298. b = append(b, symbol[j])
  299. }
  300. b = append(b, en.currencyNegativePrefix[0])
  301. } else {
  302. for j := len(symbol) - 1; j >= 0; j-- {
  303. b = append(b, symbol[j])
  304. }
  305. }
  306. // reverse
  307. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  308. b[i], b[j] = b[j], b[i]
  309. }
  310. if int(v) < 2 {
  311. if v == 0 {
  312. b = append(b, en.decimal...)
  313. }
  314. for i := 0; i < 2-int(v); i++ {
  315. b = append(b, '0')
  316. }
  317. }
  318. if num < 0 {
  319. b = append(b, en.currencyNegativeSuffix...)
  320. }
  321. return string(b)
  322. }
  323. // FmtDateShort returns the short date representation of 't' for 'en_SS'
  324. func (en *en_SS) FmtDateShort(t time.Time) string {
  325. b := make([]byte, 0, 32)
  326. b = strconv.AppendInt(b, int64(t.Month()), 10)
  327. b = append(b, []byte{0x2f}...)
  328. b = strconv.AppendInt(b, int64(t.Day()), 10)
  329. b = append(b, []byte{0x2f}...)
  330. if t.Year() > 9 {
  331. b = append(b, strconv.Itoa(t.Year())[2:]...)
  332. } else {
  333. b = append(b, strconv.Itoa(t.Year())[1:]...)
  334. }
  335. return string(b)
  336. }
  337. // FmtDateMedium returns the medium date representation of 't' for 'en_SS'
  338. func (en *en_SS) FmtDateMedium(t time.Time) string {
  339. b := make([]byte, 0, 32)
  340. b = append(b, en.monthsAbbreviated[t.Month()]...)
  341. b = append(b, []byte{0x20}...)
  342. b = strconv.AppendInt(b, int64(t.Day()), 10)
  343. b = append(b, []byte{0x2c, 0x20}...)
  344. b = strconv.AppendInt(b, int64(t.Year()), 10)
  345. return string(b)
  346. }
  347. // FmtDateLong returns the long date representation of 't' for 'en_SS'
  348. func (en *en_SS) FmtDateLong(t time.Time) string {
  349. b := make([]byte, 0, 32)
  350. b = append(b, en.monthsWide[t.Month()]...)
  351. b = append(b, []byte{0x20}...)
  352. b = strconv.AppendInt(b, int64(t.Day()), 10)
  353. b = append(b, []byte{0x2c, 0x20}...)
  354. b = strconv.AppendInt(b, int64(t.Year()), 10)
  355. return string(b)
  356. }
  357. // FmtDateFull returns the full date representation of 't' for 'en_SS'
  358. func (en *en_SS) FmtDateFull(t time.Time) string {
  359. b := make([]byte, 0, 32)
  360. b = append(b, en.daysWide[t.Weekday()]...)
  361. b = append(b, []byte{0x2c, 0x20}...)
  362. b = append(b, en.monthsWide[t.Month()]...)
  363. b = append(b, []byte{0x20}...)
  364. b = strconv.AppendInt(b, int64(t.Day()), 10)
  365. b = append(b, []byte{0x2c, 0x20}...)
  366. b = strconv.AppendInt(b, int64(t.Year()), 10)
  367. return string(b)
  368. }
  369. // FmtTimeShort returns the short time representation of 't' for 'en_SS'
  370. func (en *en_SS) FmtTimeShort(t time.Time) string {
  371. b := make([]byte, 0, 32)
  372. h := t.Hour()
  373. if h > 12 {
  374. h -= 12
  375. }
  376. b = strconv.AppendInt(b, int64(h), 10)
  377. b = append(b, en.timeSeparator...)
  378. if t.Minute() < 10 {
  379. b = append(b, '0')
  380. }
  381. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  382. b = append(b, []byte{0x20}...)
  383. if t.Hour() < 12 {
  384. b = append(b, en.periodsAbbreviated[0]...)
  385. } else {
  386. b = append(b, en.periodsAbbreviated[1]...)
  387. }
  388. return string(b)
  389. }
  390. // FmtTimeMedium returns the medium time representation of 't' for 'en_SS'
  391. func (en *en_SS) FmtTimeMedium(t time.Time) string {
  392. b := make([]byte, 0, 32)
  393. h := t.Hour()
  394. if h > 12 {
  395. h -= 12
  396. }
  397. b = strconv.AppendInt(b, int64(h), 10)
  398. b = append(b, en.timeSeparator...)
  399. if t.Minute() < 10 {
  400. b = append(b, '0')
  401. }
  402. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  403. b = append(b, en.timeSeparator...)
  404. if t.Second() < 10 {
  405. b = append(b, '0')
  406. }
  407. b = strconv.AppendInt(b, int64(t.Second()), 10)
  408. b = append(b, []byte{0x20}...)
  409. if t.Hour() < 12 {
  410. b = append(b, en.periodsAbbreviated[0]...)
  411. } else {
  412. b = append(b, en.periodsAbbreviated[1]...)
  413. }
  414. return string(b)
  415. }
  416. // FmtTimeLong returns the long time representation of 't' for 'en_SS'
  417. func (en *en_SS) FmtTimeLong(t time.Time) string {
  418. b := make([]byte, 0, 32)
  419. h := t.Hour()
  420. if h > 12 {
  421. h -= 12
  422. }
  423. b = strconv.AppendInt(b, int64(h), 10)
  424. b = append(b, en.timeSeparator...)
  425. if t.Minute() < 10 {
  426. b = append(b, '0')
  427. }
  428. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  429. b = append(b, en.timeSeparator...)
  430. if t.Second() < 10 {
  431. b = append(b, '0')
  432. }
  433. b = strconv.AppendInt(b, int64(t.Second()), 10)
  434. b = append(b, []byte{0x20}...)
  435. if t.Hour() < 12 {
  436. b = append(b, en.periodsAbbreviated[0]...)
  437. } else {
  438. b = append(b, en.periodsAbbreviated[1]...)
  439. }
  440. b = append(b, []byte{0x20}...)
  441. tz, _ := t.Zone()
  442. b = append(b, tz...)
  443. return string(b)
  444. }
  445. // FmtTimeFull returns the full time representation of 't' for 'en_SS'
  446. func (en *en_SS) FmtTimeFull(t time.Time) string {
  447. b := make([]byte, 0, 32)
  448. h := t.Hour()
  449. if h > 12 {
  450. h -= 12
  451. }
  452. b = strconv.AppendInt(b, int64(h), 10)
  453. b = append(b, en.timeSeparator...)
  454. if t.Minute() < 10 {
  455. b = append(b, '0')
  456. }
  457. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  458. b = append(b, en.timeSeparator...)
  459. if t.Second() < 10 {
  460. b = append(b, '0')
  461. }
  462. b = strconv.AppendInt(b, int64(t.Second()), 10)
  463. b = append(b, []byte{0x20}...)
  464. if t.Hour() < 12 {
  465. b = append(b, en.periodsAbbreviated[0]...)
  466. } else {
  467. b = append(b, en.periodsAbbreviated[1]...)
  468. }
  469. b = append(b, []byte{0x20}...)
  470. tz, _ := t.Zone()
  471. if btz, ok := en.timezones[tz]; ok {
  472. b = append(b, btz...)
  473. } else {
  474. b = append(b, tz...)
  475. }
  476. return string(b)
  477. }