nus_SS.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. package nus_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 nus_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 'nus_SS' locale
  41. func New() locales.Translator {
  42. return &nus_SS{
  43. locale: "nus_SS",
  44. pluralsCardinal: nil,
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  47. decimal: ".",
  48. group: ",",
  49. timeSeparator: ":",
  50. 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", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "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", "GBP", "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", "SSP", "STD", "STN", "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"},
  51. currencyNegativePrefix: "(",
  52. currencyNegativeSuffix: ")",
  53. monthsAbbreviated: []string{"", "Tiop", "Pɛt", "Duɔ̱ɔ̱", "Guak", "Duä", "Kor", "Pay", "Thoo", "Tɛɛ", "Laa", "Kur", "Tid"},
  54. monthsNarrow: []string{"", "T", "P", "D", "G", "D", "K", "P", "T", "T", "L", "K", "T"},
  55. monthsWide: []string{"", "Tiop thar pɛt", "Pɛt", "Duɔ̱ɔ̱ŋ", "Guak", "Duät", "Kornyoot", "Pay yie̱tni", "Tho̱o̱r", "Tɛɛr", "Laath", "Kur", "Tio̱p in di̱i̱t"},
  56. daysAbbreviated: []string{"Cäŋ", "Jiec", "Rɛw", "Diɔ̱k", "Ŋuaan", "Dhieec", "Bäkɛl"},
  57. daysNarrow: []string{"C", "J", "R", "D", "Ŋ", "D", "B"},
  58. daysWide: []string{"Cäŋ kuɔth", "Jiec la̱t", "Rɛw lätni", "Diɔ̱k lätni", "Ŋuaan lätni", "Dhieec lätni", "Bäkɛl lätni"},
  59. periodsAbbreviated: []string{"RW", "TŊ"},
  60. periodsWide: []string{"RW", "TŊ"},
  61. erasAbbreviated: []string{"AY", "ƐY"},
  62. erasNarrow: []string{"", ""},
  63. erasWide: []string{"A ka̱n Yecu ni dap", "Ɛ ca Yecu dap"},
  64. timezones: map[string]string{"SGT": "SGT", "HKST": "HKST", "MST": "MST", "SRT": "SRT", "GYT": "GYT", "NZST": "NZST", "CLST": "CLST", "LHST": "LHST", "CAT": "CAT", "CLT": "CLT", "PST": "PST", "WAST": "WAST", "WESZ": "WESZ", "ACWST": "ACWST", "MEZ": "MEZ", "WARST": "WARST", "HAT": "HAT", "VET": "VET", "HNNOMX": "HNNOMX", "HAST": "HAST", "CST": "CST", "EDT": "EDT", "WAT": "WAT", "ACWDT": "ACWDT", "HNT": "HNT", "GMT": "GMT", "AEDT": "AEDT", "SAST": "SAST", "EST": "EST", "MESZ": "MESZ", "TMT": "TMT", "CHADT": "CHADT", "HECU": "HECU", "WEZ": "WEZ", "ECT": "ECT", "EAT": "EAT", "HADT": "HADT", "HNPMX": "HNPMX", "HEPM": "HEPM", "JST": "JST", "HNEG": "HNEG", "LHDT": "LHDT", "WIT": "WIT", "COST": "COST", "ChST": "ChST", "HEPMX": "HEPMX", "GFT": "GFT", "ACDT": "ACDT", "HEEG": "HEEG", "TMST": "TMST", "CDT": "CDT", "ACST": "ACST", "HENOMX": "HENOMX", "ART": "ART", "HNCU": "HNCU", "AST": "AST", "WART": "WART", "AKDT": "AKDT", "MDT": "MDT", "OEZ": "OEZ", "COT": "COT", "CHAST": "CHAST", "AEST": "AEST", "BOT": "BOT", "IST": "IST", "HNPM": "HNPM", "UYST": "UYST", "AWST": "AWST", "ADT": "ADT", "MYT": "MYT", "AKST": "AKST", "HKT": "HKT", "ARST": "ARST", "AWDT": "AWDT", "NZDT": "NZDT", "HNOG": "HNOG", "PDT": "PDT", "WIB": "WIB", "JDT": "JDT", "OESZ": "OESZ", "BT": "BT", "∅∅∅": "∅∅∅", "WITA": "WITA", "UYT": "UYT", "HEOG": "HEOG"},
  65. }
  66. }
  67. // Locale returns the current translators string locale
  68. func (nus *nus_SS) Locale() string {
  69. return nus.locale
  70. }
  71. // PluralsCardinal returns the list of cardinal plural rules associated with 'nus_SS'
  72. func (nus *nus_SS) PluralsCardinal() []locales.PluralRule {
  73. return nus.pluralsCardinal
  74. }
  75. // PluralsOrdinal returns the list of ordinal plural rules associated with 'nus_SS'
  76. func (nus *nus_SS) PluralsOrdinal() []locales.PluralRule {
  77. return nus.pluralsOrdinal
  78. }
  79. // PluralsRange returns the list of range plural rules associated with 'nus_SS'
  80. func (nus *nus_SS) PluralsRange() []locales.PluralRule {
  81. return nus.pluralsRange
  82. }
  83. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'nus_SS'
  84. func (nus *nus_SS) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  85. return locales.PluralRuleUnknown
  86. }
  87. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'nus_SS'
  88. func (nus *nus_SS) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  89. return locales.PluralRuleUnknown
  90. }
  91. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'nus_SS'
  92. func (nus *nus_SS) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  93. return locales.PluralRuleUnknown
  94. }
  95. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  96. func (nus *nus_SS) MonthAbbreviated(month time.Month) string {
  97. return nus.monthsAbbreviated[month]
  98. }
  99. // MonthsAbbreviated returns the locales abbreviated months
  100. func (nus *nus_SS) MonthsAbbreviated() []string {
  101. return nus.monthsAbbreviated[1:]
  102. }
  103. // MonthNarrow returns the locales narrow month given the 'month' provided
  104. func (nus *nus_SS) MonthNarrow(month time.Month) string {
  105. return nus.monthsNarrow[month]
  106. }
  107. // MonthsNarrow returns the locales narrow months
  108. func (nus *nus_SS) MonthsNarrow() []string {
  109. return nus.monthsNarrow[1:]
  110. }
  111. // MonthWide returns the locales wide month given the 'month' provided
  112. func (nus *nus_SS) MonthWide(month time.Month) string {
  113. return nus.monthsWide[month]
  114. }
  115. // MonthsWide returns the locales wide months
  116. func (nus *nus_SS) MonthsWide() []string {
  117. return nus.monthsWide[1:]
  118. }
  119. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  120. func (nus *nus_SS) WeekdayAbbreviated(weekday time.Weekday) string {
  121. return nus.daysAbbreviated[weekday]
  122. }
  123. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  124. func (nus *nus_SS) WeekdaysAbbreviated() []string {
  125. return nus.daysAbbreviated
  126. }
  127. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  128. func (nus *nus_SS) WeekdayNarrow(weekday time.Weekday) string {
  129. return nus.daysNarrow[weekday]
  130. }
  131. // WeekdaysNarrow returns the locales narrow weekdays
  132. func (nus *nus_SS) WeekdaysNarrow() []string {
  133. return nus.daysNarrow
  134. }
  135. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  136. func (nus *nus_SS) WeekdayShort(weekday time.Weekday) string {
  137. return nus.daysShort[weekday]
  138. }
  139. // WeekdaysShort returns the locales short weekdays
  140. func (nus *nus_SS) WeekdaysShort() []string {
  141. return nus.daysShort
  142. }
  143. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  144. func (nus *nus_SS) WeekdayWide(weekday time.Weekday) string {
  145. return nus.daysWide[weekday]
  146. }
  147. // WeekdaysWide returns the locales wide weekdays
  148. func (nus *nus_SS) WeekdaysWide() []string {
  149. return nus.daysWide
  150. }
  151. // Decimal returns the decimal point of number
  152. func (nus *nus_SS) Decimal() string {
  153. return nus.decimal
  154. }
  155. // Group returns the group of number
  156. func (nus *nus_SS) Group() string {
  157. return nus.group
  158. }
  159. // Group returns the minus sign of number
  160. func (nus *nus_SS) Minus() string {
  161. return nus.minus
  162. }
  163. // FmtNumber returns 'num' with digits/precision of 'v' for 'nus_SS' and handles both Whole and Real numbers based on 'v'
  164. func (nus *nus_SS) FmtNumber(num float64, v uint64) string {
  165. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  166. l := len(s) + 1 + 1*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, nus.decimal[0])
  173. inWhole = true
  174. continue
  175. }
  176. if inWhole {
  177. if count == 3 {
  178. b = append(b, nus.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, nus.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 string(b)
  194. }
  195. // FmtPercent returns 'num' with digits/precision of 'v' for 'nus_SS' and handles both Whole and Real numbers based on 'v'
  196. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  197. func (nus *nus_SS) FmtPercent(num float64, v uint64) string {
  198. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  199. l := len(s) + 1
  200. b := make([]byte, 0, l)
  201. for i := len(s) - 1; i >= 0; i-- {
  202. if s[i] == '.' {
  203. b = append(b, nus.decimal[0])
  204. continue
  205. }
  206. b = append(b, s[i])
  207. }
  208. if num < 0 {
  209. b = append(b, nus.minus[0])
  210. }
  211. // reverse
  212. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  213. b[i], b[j] = b[j], b[i]
  214. }
  215. b = append(b, nus.percent...)
  216. return string(b)
  217. }
  218. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'nus_SS'
  219. func (nus *nus_SS) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  220. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  221. symbol := nus.currencies[currency]
  222. l := len(s) + len(symbol) + 1 + 1*len(s[:len(s)-int(v)-1])/3
  223. count := 0
  224. inWhole := v == 0
  225. b := make([]byte, 0, l)
  226. for i := len(s) - 1; i >= 0; i-- {
  227. if s[i] == '.' {
  228. b = append(b, nus.decimal[0])
  229. inWhole = true
  230. continue
  231. }
  232. if inWhole {
  233. if count == 3 {
  234. b = append(b, nus.group[0])
  235. count = 1
  236. } else {
  237. count++
  238. }
  239. }
  240. b = append(b, s[i])
  241. }
  242. for j := len(symbol) - 1; j >= 0; j-- {
  243. b = append(b, symbol[j])
  244. }
  245. if num < 0 {
  246. b = append(b, nus.minus[0])
  247. }
  248. // reverse
  249. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  250. b[i], b[j] = b[j], b[i]
  251. }
  252. if int(v) < 2 {
  253. if v == 0 {
  254. b = append(b, nus.decimal...)
  255. }
  256. for i := 0; i < 2-int(v); i++ {
  257. b = append(b, '0')
  258. }
  259. }
  260. return string(b)
  261. }
  262. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'nus_SS'
  263. // in accounting notation.
  264. func (nus *nus_SS) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  265. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  266. symbol := nus.currencies[currency]
  267. l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3
  268. count := 0
  269. inWhole := v == 0
  270. b := make([]byte, 0, l)
  271. for i := len(s) - 1; i >= 0; i-- {
  272. if s[i] == '.' {
  273. b = append(b, nus.decimal[0])
  274. inWhole = true
  275. continue
  276. }
  277. if inWhole {
  278. if count == 3 {
  279. b = append(b, nus.group[0])
  280. count = 1
  281. } else {
  282. count++
  283. }
  284. }
  285. b = append(b, s[i])
  286. }
  287. if num < 0 {
  288. for j := len(symbol) - 1; j >= 0; j-- {
  289. b = append(b, symbol[j])
  290. }
  291. b = append(b, nus.currencyNegativePrefix[0])
  292. } else {
  293. for j := len(symbol) - 1; j >= 0; j-- {
  294. b = append(b, symbol[j])
  295. }
  296. }
  297. // reverse
  298. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  299. b[i], b[j] = b[j], b[i]
  300. }
  301. if int(v) < 2 {
  302. if v == 0 {
  303. b = append(b, nus.decimal...)
  304. }
  305. for i := 0; i < 2-int(v); i++ {
  306. b = append(b, '0')
  307. }
  308. }
  309. if num < 0 {
  310. b = append(b, nus.currencyNegativeSuffix...)
  311. }
  312. return string(b)
  313. }
  314. // FmtDateShort returns the short date representation of 't' for 'nus_SS'
  315. func (nus *nus_SS) FmtDateShort(t time.Time) string {
  316. b := make([]byte, 0, 32)
  317. b = strconv.AppendInt(b, int64(t.Day()), 10)
  318. b = append(b, []byte{0x2f}...)
  319. if t.Month() < 10 {
  320. b = append(b, '0')
  321. }
  322. b = strconv.AppendInt(b, int64(t.Month()), 10)
  323. b = append(b, []byte{0x2f}...)
  324. if t.Year() > 0 {
  325. b = strconv.AppendInt(b, int64(t.Year()), 10)
  326. } else {
  327. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  328. }
  329. return string(b)
  330. }
  331. // FmtDateMedium returns the medium date representation of 't' for 'nus_SS'
  332. func (nus *nus_SS) FmtDateMedium(t time.Time) string {
  333. b := make([]byte, 0, 32)
  334. b = strconv.AppendInt(b, int64(t.Day()), 10)
  335. b = append(b, []byte{0x20}...)
  336. b = append(b, nus.monthsAbbreviated[t.Month()]...)
  337. b = append(b, []byte{0x20}...)
  338. if t.Year() > 0 {
  339. b = strconv.AppendInt(b, int64(t.Year()), 10)
  340. } else {
  341. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  342. }
  343. return string(b)
  344. }
  345. // FmtDateLong returns the long date representation of 't' for 'nus_SS'
  346. func (nus *nus_SS) FmtDateLong(t time.Time) string {
  347. b := make([]byte, 0, 32)
  348. b = strconv.AppendInt(b, int64(t.Day()), 10)
  349. b = append(b, []byte{0x20}...)
  350. b = append(b, nus.monthsWide[t.Month()]...)
  351. b = append(b, []byte{0x20}...)
  352. if t.Year() > 0 {
  353. b = strconv.AppendInt(b, int64(t.Year()), 10)
  354. } else {
  355. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  356. }
  357. return string(b)
  358. }
  359. // FmtDateFull returns the full date representation of 't' for 'nus_SS'
  360. func (nus *nus_SS) FmtDateFull(t time.Time) string {
  361. b := make([]byte, 0, 32)
  362. b = append(b, nus.daysWide[t.Weekday()]...)
  363. b = append(b, []byte{0x20}...)
  364. b = strconv.AppendInt(b, int64(t.Day()), 10)
  365. b = append(b, []byte{0x20}...)
  366. b = append(b, nus.monthsWide[t.Month()]...)
  367. b = append(b, []byte{0x20}...)
  368. if t.Year() > 0 {
  369. b = strconv.AppendInt(b, int64(t.Year()), 10)
  370. } else {
  371. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  372. }
  373. return string(b)
  374. }
  375. // FmtTimeShort returns the short time representation of 't' for 'nus_SS'
  376. func (nus *nus_SS) FmtTimeShort(t time.Time) string {
  377. b := make([]byte, 0, 32)
  378. h := t.Hour()
  379. if h > 12 {
  380. h -= 12
  381. }
  382. b = strconv.AppendInt(b, int64(h), 10)
  383. b = append(b, nus.timeSeparator...)
  384. if t.Minute() < 10 {
  385. b = append(b, '0')
  386. }
  387. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  388. b = append(b, []byte{0x20}...)
  389. if t.Hour() < 12 {
  390. b = append(b, nus.periodsAbbreviated[0]...)
  391. } else {
  392. b = append(b, nus.periodsAbbreviated[1]...)
  393. }
  394. return string(b)
  395. }
  396. // FmtTimeMedium returns the medium time representation of 't' for 'nus_SS'
  397. func (nus *nus_SS) FmtTimeMedium(t time.Time) string {
  398. b := make([]byte, 0, 32)
  399. h := t.Hour()
  400. if h > 12 {
  401. h -= 12
  402. }
  403. b = strconv.AppendInt(b, int64(h), 10)
  404. b = append(b, nus.timeSeparator...)
  405. if t.Minute() < 10 {
  406. b = append(b, '0')
  407. }
  408. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  409. b = append(b, nus.timeSeparator...)
  410. if t.Second() < 10 {
  411. b = append(b, '0')
  412. }
  413. b = strconv.AppendInt(b, int64(t.Second()), 10)
  414. b = append(b, []byte{0x20}...)
  415. if t.Hour() < 12 {
  416. b = append(b, nus.periodsAbbreviated[0]...)
  417. } else {
  418. b = append(b, nus.periodsAbbreviated[1]...)
  419. }
  420. return string(b)
  421. }
  422. // FmtTimeLong returns the long time representation of 't' for 'nus_SS'
  423. func (nus *nus_SS) FmtTimeLong(t time.Time) string {
  424. b := make([]byte, 0, 32)
  425. tz, _ := t.Zone()
  426. b = append(b, tz...)
  427. b = append(b, []byte{0x20}...)
  428. h := t.Hour()
  429. if h > 12 {
  430. h -= 12
  431. }
  432. b = strconv.AppendInt(b, int64(h), 10)
  433. b = append(b, nus.timeSeparator...)
  434. if t.Minute() < 10 {
  435. b = append(b, '0')
  436. }
  437. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  438. b = append(b, nus.timeSeparator...)
  439. if t.Second() < 10 {
  440. b = append(b, '0')
  441. }
  442. b = strconv.AppendInt(b, int64(t.Second()), 10)
  443. b = append(b, []byte{0x20}...)
  444. if t.Hour() < 12 {
  445. b = append(b, nus.periodsAbbreviated[0]...)
  446. } else {
  447. b = append(b, nus.periodsAbbreviated[1]...)
  448. }
  449. return string(b)
  450. }
  451. // FmtTimeFull returns the full time representation of 't' for 'nus_SS'
  452. func (nus *nus_SS) FmtTimeFull(t time.Time) string {
  453. b := make([]byte, 0, 32)
  454. tz, _ := t.Zone()
  455. if btz, ok := nus.timezones[tz]; ok {
  456. b = append(b, btz...)
  457. } else {
  458. b = append(b, tz...)
  459. }
  460. b = append(b, []byte{0x20}...)
  461. h := t.Hour()
  462. if h > 12 {
  463. h -= 12
  464. }
  465. b = strconv.AppendInt(b, int64(h), 10)
  466. b = append(b, nus.timeSeparator...)
  467. if t.Minute() < 10 {
  468. b = append(b, '0')
  469. }
  470. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  471. b = append(b, nus.timeSeparator...)
  472. if t.Second() < 10 {
  473. b = append(b, '0')
  474. }
  475. b = strconv.AppendInt(b, int64(t.Second()), 10)
  476. b = append(b, []byte{0x20}...)
  477. if t.Hour() < 12 {
  478. b = append(b, nus.periodsAbbreviated[0]...)
  479. } else {
  480. b = append(b, nus.periodsAbbreviated[1]...)
  481. }
  482. return string(b)
  483. }