id_ID.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. package id_ID
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type id_ID 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. monthsAbbreviated []string
  23. monthsNarrow []string
  24. monthsWide []string
  25. daysAbbreviated []string
  26. daysNarrow []string
  27. daysShort []string
  28. daysWide []string
  29. periodsAbbreviated []string
  30. periodsNarrow []string
  31. periodsShort []string
  32. periodsWide []string
  33. erasAbbreviated []string
  34. erasNarrow []string
  35. erasWide []string
  36. timezones map[string]string
  37. }
  38. // New returns a new instance of translator for the 'id_ID' locale
  39. func New() locales.Translator {
  40. return &id_ID{
  41. locale: "id_ID",
  42. pluralsCardinal: []locales.PluralRule{6},
  43. pluralsOrdinal: []locales.PluralRule{6},
  44. pluralsRange: []locales.PluralRule{6},
  45. decimal: ",",
  46. group: ".",
  47. minus: "-",
  48. percent: "%",
  49. perMille: "‰",
  50. timeSeparator: ".",
  51. inifinity: "∞",
  52. 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 ", "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 ", "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 "},
  53. monthsAbbreviated: []string{"", "Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agt", "Sep", "Okt", "Nov", "Des"},
  54. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  55. monthsWide: []string{"", "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"},
  56. daysAbbreviated: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"},
  57. daysNarrow: []string{"M", "S", "S", "R", "K", "J", "S"},
  58. daysShort: []string{"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"},
  59. daysWide: []string{"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"},
  60. periodsAbbreviated: []string{"AM", "PM"},
  61. periodsNarrow: []string{"AM", "PM"},
  62. periodsWide: []string{"AM", "PM"},
  63. erasAbbreviated: []string{"SM", "M"},
  64. erasNarrow: []string{"SM", "M"},
  65. erasWide: []string{"Sebelum Masehi", "M"},
  66. timezones: map[string]string{"AWDT": "Waktu Musim Panas Barat Australia", "BOT": "Waktu Bolivia", "AEST": "Waktu Standar Timur Australia", "GYT": "Waktu Guyana", "MEZ": "Waktu Standar Eropa Tengah", "EDT": "Waktu Musim Panas Timur", "ECT": "Waktu Ekuador", "EST": "Waktu Standar Timur", "BT": "Waktu Bhutan", "WIB": "Waktu Indonesia Barat", "PDT": "Waktu Musim Panas Pasifik", "UYT": "Waktu Standar Uruguay", "CLST": "Waktu Musim Panas Cile", "ACWST": "Waktu Standar Barat Tengah Australia", "WAT": "Waktu Standar Afrika Barat", "MESZ": "Waktu Musim Panas Eropa Tengah", "ACWDT": "Waktu Musim Panas Barat Tengah Australia", "AST": "Waktu Standar Atlantik", "IST": "Waktu India", "WITA": "Waktu Indonesia Tengah", "LHDT": "Waktu Musim Panas Lord Howe", "NZST": "Waktu Standar Selandia Baru", "MDT": "Waktu Musim Panas Makau", "JDT": "Waktu Musim Panas Jepang", "AKST": "Waktu Standar Alaska", "AKDT": "Waktu Musim Panas Alaska", "AWST": "Waktu Standar Barat Australia", "LHST": "Waktu Standar Lord Howe", "NZDT": "Waktu Musim Panas Selandia Baru", "VET": "Waktu Venezuela", "ChST": "Waktu Chamorro", "COT": "Waktu Standar Kolombia", "SGT": "Waktu Standar Singapura", "GFT": "Waktu Guyana Prancis", "WESZ": "Waktu Musim Panas Eropa Barat", "WIT": "Waktu Indonesia Timur", "OEZ": "Waktu Standar Eropa Timur", "HNT": "Waktu Standar Newfoundland", "EAT": "Waktu Afrika Timur", "ACST": "Waktu Standar Tengah Australia", "ACDT": "Waktu Musim Panas Tengah Australia", "CHAST": "Waktu Standar Chatham", "CAT": "Waktu Afrika Tengah", "OESZ": "Waktu Musim Panas Eropa Timur", "WARST": "Waktu Musim Panas Argentina Bagian Barat", "∅∅∅": "Waktu Musim Panas Amazon", "PST": "Waktu Standar Pasifik", "UYST": "Waktu Musim Panas Uruguay", "AEDT": "Waktu Musim Panas Timur Australia", "HKT": "Waktu Standar Hong Kong", "HKST": "Waktu Musim Panas Hong Kong", "ART": "Waktu Standar Argentina", "ARST": "Waktu Musim Panas Argentina", "HADT": "Waktu Musim Panas Hawaii-Aleutian", "TMST": "Waktu Musim Panas Turkmenistan", "COST": "Waktu Musim Panas Kolombia", "HAT": "Waktu Musim Panas Newfoundland", "MST": "Waktu Standar Makau", "CST": "Waktu Standar Tengah", "ADT": "Waktu Musim Panas Atlantik", "HAST": "Waktu Standar Hawaii-Aleutian", "GMT": "Waktu Rata-rata Greenwich", "WART": "Waktu Standar Argentina Bagian Barat", "JST": "Waktu Standar Jepang", "SRT": "Waktu Suriname", "CDT": "Waktu Musim Panas Tengah", "CLT": "Waktu Standar Cile", "SAST": "Waktu Standar Afrika Selatan", "WAST": "Waktu Musim Panas Afrika Barat", "MYT": "Waktu Malaysia", "TMT": "Waktu Standar Turkmenistan", "WEZ": "Waktu Standar Eropa Barat", "CHADT": "Waktu Musim Panas Chatham"},
  67. }
  68. }
  69. // Locale returns the current translators string locale
  70. func (id *id_ID) Locale() string {
  71. return id.locale
  72. }
  73. // PluralsCardinal returns the list of cardinal plural rules associated with 'id_ID'
  74. func (id *id_ID) PluralsCardinal() []locales.PluralRule {
  75. return id.pluralsCardinal
  76. }
  77. // PluralsOrdinal returns the list of ordinal plural rules associated with 'id_ID'
  78. func (id *id_ID) PluralsOrdinal() []locales.PluralRule {
  79. return id.pluralsOrdinal
  80. }
  81. // PluralsRange returns the list of range plural rules associated with 'id_ID'
  82. func (id *id_ID) PluralsRange() []locales.PluralRule {
  83. return id.pluralsRange
  84. }
  85. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'id_ID'
  86. func (id *id_ID) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  87. return locales.PluralRuleOther
  88. }
  89. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'id_ID'
  90. func (id *id_ID) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. return locales.PluralRuleOther
  92. }
  93. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'id_ID'
  94. func (id *id_ID) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  95. return locales.PluralRuleOther
  96. }
  97. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  98. func (id *id_ID) MonthAbbreviated(month time.Month) string {
  99. return id.monthsAbbreviated[month]
  100. }
  101. // MonthsAbbreviated returns the locales abbreviated months
  102. func (id *id_ID) MonthsAbbreviated() []string {
  103. return id.monthsAbbreviated[1:]
  104. }
  105. // MonthNarrow returns the locales narrow month given the 'month' provided
  106. func (id *id_ID) MonthNarrow(month time.Month) string {
  107. return id.monthsNarrow[month]
  108. }
  109. // MonthsNarrow returns the locales narrow months
  110. func (id *id_ID) MonthsNarrow() []string {
  111. return id.monthsNarrow[1:]
  112. }
  113. // MonthWide returns the locales wide month given the 'month' provided
  114. func (id *id_ID) MonthWide(month time.Month) string {
  115. return id.monthsWide[month]
  116. }
  117. // MonthsWide returns the locales wide months
  118. func (id *id_ID) MonthsWide() []string {
  119. return id.monthsWide[1:]
  120. }
  121. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  122. func (id *id_ID) WeekdayAbbreviated(weekday time.Weekday) string {
  123. return id.daysAbbreviated[weekday]
  124. }
  125. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  126. func (id *id_ID) WeekdaysAbbreviated() []string {
  127. return id.daysAbbreviated
  128. }
  129. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  130. func (id *id_ID) WeekdayNarrow(weekday time.Weekday) string {
  131. return id.daysNarrow[weekday]
  132. }
  133. // WeekdaysNarrow returns the locales narrow weekdays
  134. func (id *id_ID) WeekdaysNarrow() []string {
  135. return id.daysNarrow
  136. }
  137. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  138. func (id *id_ID) WeekdayShort(weekday time.Weekday) string {
  139. return id.daysShort[weekday]
  140. }
  141. // WeekdaysShort returns the locales short weekdays
  142. func (id *id_ID) WeekdaysShort() []string {
  143. return id.daysShort
  144. }
  145. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  146. func (id *id_ID) WeekdayWide(weekday time.Weekday) string {
  147. return id.daysWide[weekday]
  148. }
  149. // WeekdaysWide returns the locales wide weekdays
  150. func (id *id_ID) WeekdaysWide() []string {
  151. return id.daysWide
  152. }
  153. // FmtNumber returns 'num' with digits/precision of 'v' for 'id_ID' and handles both Whole and Real numbers based on 'v'
  154. func (id *id_ID) FmtNumber(num float64, v uint64) string {
  155. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  156. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  157. count := 0
  158. inWhole := v == 0
  159. b := make([]byte, 0, l)
  160. for i := len(s) - 1; i >= 0; i-- {
  161. if s[i] == '.' {
  162. b = append(b, id.decimal[0])
  163. inWhole = true
  164. continue
  165. }
  166. if inWhole {
  167. if count == 3 {
  168. b = append(b, id.group[0])
  169. count = 1
  170. } else {
  171. count++
  172. }
  173. }
  174. b = append(b, s[i])
  175. }
  176. if num < 0 {
  177. b = append(b, id.minus[0])
  178. }
  179. // reverse
  180. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  181. b[i], b[j] = b[j], b[i]
  182. }
  183. return string(b)
  184. }
  185. // FmtPercent returns 'num' with digits/precision of 'v' for 'id_ID' and handles both Whole and Real numbers based on 'v'
  186. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  187. func (id *id_ID) FmtPercent(num float64, v uint64) string {
  188. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  189. l := len(s) + 3
  190. b := make([]byte, 0, l)
  191. for i := len(s) - 1; i >= 0; i-- {
  192. if s[i] == '.' {
  193. b = append(b, id.decimal[0])
  194. continue
  195. }
  196. b = append(b, s[i])
  197. }
  198. if num < 0 {
  199. b = append(b, id.minus[0])
  200. }
  201. // reverse
  202. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  203. b[i], b[j] = b[j], b[i]
  204. }
  205. b = append(b, id.percent...)
  206. return string(b)
  207. }
  208. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'id_ID'
  209. func (id *id_ID) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  210. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  211. symbol := id.currencies[currency]
  212. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  213. count := 0
  214. inWhole := v == 0
  215. b := make([]byte, 0, l)
  216. for i := len(s) - 1; i >= 0; i-- {
  217. if s[i] == '.' {
  218. b = append(b, id.decimal[0])
  219. inWhole = true
  220. continue
  221. }
  222. if inWhole {
  223. if count == 3 {
  224. b = append(b, id.group[0])
  225. count = 1
  226. } else {
  227. count++
  228. }
  229. }
  230. b = append(b, s[i])
  231. }
  232. for j := len(symbol) - 1; j >= 0; j-- {
  233. b = append(b, symbol[j])
  234. }
  235. if num < 0 {
  236. b = append(b, id.minus[0])
  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. if int(v) < 2 {
  243. if v == 0 {
  244. b = append(b, id.decimal...)
  245. }
  246. for i := 0; i < 2-int(v); i++ {
  247. b = append(b, '0')
  248. }
  249. }
  250. return string(b)
  251. }
  252. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'id_ID'
  253. // in accounting notation.
  254. func (id *id_ID) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  255. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  256. symbol := id.currencies[currency]
  257. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  258. count := 0
  259. inWhole := v == 0
  260. b := make([]byte, 0, l)
  261. for i := len(s) - 1; i >= 0; i-- {
  262. if s[i] == '.' {
  263. b = append(b, id.decimal[0])
  264. inWhole = true
  265. continue
  266. }
  267. if inWhole {
  268. if count == 3 {
  269. b = append(b, id.group[0])
  270. count = 1
  271. } else {
  272. count++
  273. }
  274. }
  275. b = append(b, s[i])
  276. }
  277. if num < 0 {
  278. for j := len(symbol) - 1; j >= 0; j-- {
  279. b = append(b, symbol[j])
  280. }
  281. b = append(b, id.minus[0])
  282. } else {
  283. for j := len(symbol) - 1; j >= 0; j-- {
  284. b = append(b, symbol[j])
  285. }
  286. }
  287. // reverse
  288. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  289. b[i], b[j] = b[j], b[i]
  290. }
  291. if int(v) < 2 {
  292. if v == 0 {
  293. b = append(b, id.decimal...)
  294. }
  295. for i := 0; i < 2-int(v); i++ {
  296. b = append(b, '0')
  297. }
  298. }
  299. return string(b)
  300. }
  301. // FmtDateShort returns the short date representation of 't' for 'id_ID'
  302. func (id *id_ID) FmtDateShort(t time.Time) string {
  303. b := make([]byte, 0, 32)
  304. if t.Day() < 10 {
  305. b = append(b, '0')
  306. }
  307. b = strconv.AppendInt(b, int64(t.Day()), 10)
  308. b = append(b, []byte{0x2f}...)
  309. if t.Month() < 10 {
  310. b = append(b, '0')
  311. }
  312. b = strconv.AppendInt(b, int64(t.Month()), 10)
  313. b = append(b, []byte{0x2f}...)
  314. if t.Year() > 9 {
  315. b = append(b, strconv.Itoa(t.Year())[2:]...)
  316. } else {
  317. b = append(b, strconv.Itoa(t.Year())[1:]...)
  318. }
  319. return string(b)
  320. }
  321. // FmtDateMedium returns the medium date representation of 't' for 'id_ID'
  322. func (id *id_ID) FmtDateMedium(t time.Time) string {
  323. b := make([]byte, 0, 32)
  324. b = strconv.AppendInt(b, int64(t.Day()), 10)
  325. b = append(b, []byte{0x20}...)
  326. b = append(b, id.monthsAbbreviated[t.Month()]...)
  327. b = append(b, []byte{0x20}...)
  328. b = strconv.AppendInt(b, int64(t.Year()), 10)
  329. return string(b)
  330. }
  331. // FmtDateLong returns the long date representation of 't' for 'id_ID'
  332. func (id *id_ID) FmtDateLong(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, id.monthsWide[t.Month()]...)
  337. b = append(b, []byte{0x20}...)
  338. b = strconv.AppendInt(b, int64(t.Year()), 10)
  339. return string(b)
  340. }
  341. // FmtDateFull returns the full date representation of 't' for 'id_ID'
  342. func (id *id_ID) FmtDateFull(t time.Time) string {
  343. b := make([]byte, 0, 32)
  344. b = append(b, id.daysWide[t.Weekday()]...)
  345. b = append(b, []byte{0x2c, 0x20}...)
  346. if t.Day() < 10 {
  347. b = append(b, '0')
  348. }
  349. b = strconv.AppendInt(b, int64(t.Day()), 10)
  350. b = append(b, []byte{0x20}...)
  351. b = append(b, id.monthsWide[t.Month()]...)
  352. b = append(b, []byte{0x20}...)
  353. b = strconv.AppendInt(b, int64(t.Year()), 10)
  354. return string(b)
  355. }
  356. // FmtTimeShort returns the short time representation of 't' for 'id_ID'
  357. func (id *id_ID) FmtTimeShort(t time.Time) string {
  358. b := make([]byte, 0, 32)
  359. if t.Hour() < 10 {
  360. b = append(b, '0')
  361. }
  362. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  363. b = append(b, []byte{0x2e}...)
  364. if t.Minute() < 10 {
  365. b = append(b, '0')
  366. }
  367. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  368. return string(b)
  369. }
  370. // FmtTimeMedium returns the medium time representation of 't' for 'id_ID'
  371. func (id *id_ID) FmtTimeMedium(t time.Time) string {
  372. b := make([]byte, 0, 32)
  373. if t.Hour() < 10 {
  374. b = append(b, '0')
  375. }
  376. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  377. b = append(b, []byte{0x2e}...)
  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{0x2e}...)
  383. if t.Second() < 10 {
  384. b = append(b, '0')
  385. }
  386. b = strconv.AppendInt(b, int64(t.Second()), 10)
  387. return string(b)
  388. }
  389. // FmtTimeLong returns the long time representation of 't' for 'id_ID'
  390. func (id *id_ID) FmtTimeLong(t time.Time) string {
  391. b := make([]byte, 0, 32)
  392. if t.Hour() < 10 {
  393. b = append(b, '0')
  394. }
  395. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  396. b = append(b, []byte{0x2e}...)
  397. if t.Minute() < 10 {
  398. b = append(b, '0')
  399. }
  400. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  401. b = append(b, []byte{0x2e}...)
  402. if t.Second() < 10 {
  403. b = append(b, '0')
  404. }
  405. b = strconv.AppendInt(b, int64(t.Second()), 10)
  406. b = append(b, []byte{0x20}...)
  407. tz, _ := t.Zone()
  408. b = append(b, tz...)
  409. return string(b)
  410. }
  411. // FmtTimeFull returns the full time representation of 't' for 'id_ID'
  412. func (id *id_ID) FmtTimeFull(t time.Time) string {
  413. b := make([]byte, 0, 32)
  414. if t.Hour() < 10 {
  415. b = append(b, '0')
  416. }
  417. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  418. b = append(b, []byte{0x2e}...)
  419. if t.Minute() < 10 {
  420. b = append(b, '0')
  421. }
  422. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  423. b = append(b, []byte{0x2e}...)
  424. if t.Second() < 10 {
  425. b = append(b, '0')
  426. }
  427. b = strconv.AppendInt(b, int64(t.Second()), 10)
  428. b = append(b, []byte{0x20}...)
  429. tz, _ := t.Zone()
  430. if btz, ok := id.timezones[tz]; ok {
  431. b = append(b, btz...)
  432. } else {
  433. b = append(b, tz...)
  434. }
  435. return string(b)
  436. }