id_ID.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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", "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"},
  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", "Masehi"},
  66. timezones: map[string]string{"MST": "Waktu Standar Pegunungan", "WIT": "Waktu Indonesia Timur", "CHADT": "Waktu Musim Panas Chatham", "COST": "Waktu Musim Panas Kolombia", "∅∅∅": "Waktu Musim Panas Amazon", "GMT": "Greenwich Mean Time", "AWDT": "Waktu Musim Panas Barat Australia", "WAST": "Waktu Musim Panas Afrika Barat", "BOT": "Waktu Bolivia", "ECT": "Waktu Ekuador", "ART": "Waktu Standar Argentina", "WARST": "Waktu Musim Panas Argentina Bagian Barat", "WITA": "Waktu Indonesia Tengah", "HNEG": "Waktu Standar Greenland Timur", "ACWST": "Waktu Standar Barat Tengah Australia", "MEZ": "Waktu Standar Eropa Tengah", "JDT": "Waktu Musim Panas Jepang", "JST": "Waktu Standar Jepang", "AKST": "Waktu Standar Alaska", "CAT": "Waktu Afrika Tengah", "HNPMX": "Waktu Standar Pasifik Meksiko", "AEDT": "Waktu Musim Panas Timur Australia", "MDT": "Waktu Musim Panas Pegunungan", "NZDT": "Waktu Musim Panas Selandia Baru", "GFT": "Waktu Guyana Prancis", "MESZ": "Waktu Musim Panas Eropa Tengah", "VET": "Waktu Venezuela", "TMST": "Waktu Musim Panas Turkmenistan", "ARST": "Waktu Musim Panas Argentina", "ACDT": "Waktu Musim Panas Tengah Australia", "HNT": "Waktu Standar Newfoundland", "MYT": "Waktu Malaysia", "HAT": "Waktu Musim Panas Newfoundland", "HENOMX": "Waktu Musim Panas Meksiko Barat Laut", "ADT": "Waktu Musim Panas Atlantik", "HECU": "Waktu Musim Panas Kuba", "AWST": "Waktu Standar Barat Australia", "WAT": "Waktu Standar Afrika Barat", "ACWDT": "Waktu Musim Panas Barat Tengah Australia", "EDT": "Waktu Musim Panas Timur", "HKST": "Waktu Musim Panas Hong Kong", "CLST": "Waktu Musim Panas Cile", "HADT": "Waktu Musim Panas Hawaii-Aleutian", "HEPMX": "Waktu Musim Panas Pasifik Meksiko", "CDT": "Waktu Musim Panas Tengah", "LHST": "Waktu Standar Lord Howe", "HEPM": "Waktu Musim Panas Saint Pierre dan Miquelon", "COT": "Waktu Standar Kolombia", "HEOG": "Waktu Musim Panas Greenland Barat", "EST": "Waktu Standar Timur", "HNNOMX": "Waktu Standar Meksiko Barat Laut", "EAT": "Waktu Afrika Timur", "CLT": "Waktu Standar Cile", "OEZ": "Waktu Standar Eropa Timur", "ChST": "Waktu Standar Chamorro", "CHAST": "Waktu Standar Chatham", "AKDT": "Waktu Musim Panas Alaska", "ACST": "Waktu Standar Tengah Australia", "HNOG": "Waktu Standar Greenland Barat", "WART": "Waktu Standar Argentina Bagian Barat", "UYST": "Waktu Musim Panas Uruguay", "UYT": "Waktu Standar Uruguay", "HNCU": "Waktu Standar Kuba", "SRT": "Waktu Suriname", "GYT": "Waktu Guyana", "AST": "Waktu Standar Atlantik", "LHDT": "Waktu Musim Panas Lord Howe", "IST": "Waktu India", "TMT": "Waktu Standar Turkmenistan", "PDT": "Waktu Musim Panas Pasifik", "PST": "Waktu Standar Pasifik", "WEZ": "Waktu Standar Eropa Barat", "WESZ": "Waktu Musim Panas Eropa Barat", "WIB": "Waktu Indonesia Barat", "SAST": "Waktu Standar Afrika Selatan", "HEEG": "Waktu Musim Panas Greenland Timur", "HKT": "Waktu Standar Hong Kong", "OESZ": "Waktu Musim Panas Eropa Timur", "HNPM": "Waktu Standar Saint Pierre dan Miquelon", "NZST": "Waktu Standar Selandia Baru", "SGT": "Waktu Standar Singapura", "HAST": "Waktu Standar Hawaii-Aleutian", "AEST": "Waktu Standar Timur Australia", "BT": "Waktu Bhutan", "CST": "Waktu Standar Tengah"},
  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. // Decimal returns the decimal point of number
  154. func (id *id_ID) Decimal() string {
  155. return id.decimal
  156. }
  157. // Group returns the group of number
  158. func (id *id_ID) Group() string {
  159. return id.group
  160. }
  161. // Group returns the minus sign of number
  162. func (id *id_ID) Minus() string {
  163. return id.minus
  164. }
  165. // FmtNumber returns 'num' with digits/precision of 'v' for 'id_ID' and handles both Whole and Real numbers based on 'v'
  166. func (id *id_ID) FmtNumber(num float64, v uint64) string {
  167. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  168. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  169. count := 0
  170. inWhole := v == 0
  171. b := make([]byte, 0, l)
  172. for i := len(s) - 1; i >= 0; i-- {
  173. if s[i] == '.' {
  174. b = append(b, id.decimal[0])
  175. inWhole = true
  176. continue
  177. }
  178. if inWhole {
  179. if count == 3 {
  180. b = append(b, id.group[0])
  181. count = 1
  182. } else {
  183. count++
  184. }
  185. }
  186. b = append(b, s[i])
  187. }
  188. if num < 0 {
  189. b = append(b, id.minus[0])
  190. }
  191. // reverse
  192. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  193. b[i], b[j] = b[j], b[i]
  194. }
  195. return string(b)
  196. }
  197. // FmtPercent returns 'num' with digits/precision of 'v' for 'id_ID' and handles both Whole and Real numbers based on 'v'
  198. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  199. func (id *id_ID) FmtPercent(num float64, v uint64) string {
  200. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  201. l := len(s) + 3
  202. b := make([]byte, 0, l)
  203. for i := len(s) - 1; i >= 0; i-- {
  204. if s[i] == '.' {
  205. b = append(b, id.decimal[0])
  206. continue
  207. }
  208. b = append(b, s[i])
  209. }
  210. if num < 0 {
  211. b = append(b, id.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, id.percent...)
  218. return string(b)
  219. }
  220. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'id_ID'
  221. func (id *id_ID) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  222. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  223. symbol := id.currencies[currency]
  224. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  225. count := 0
  226. inWhole := v == 0
  227. b := make([]byte, 0, l)
  228. for i := len(s) - 1; i >= 0; i-- {
  229. if s[i] == '.' {
  230. b = append(b, id.decimal[0])
  231. inWhole = true
  232. continue
  233. }
  234. if inWhole {
  235. if count == 3 {
  236. b = append(b, id.group[0])
  237. count = 1
  238. } else {
  239. count++
  240. }
  241. }
  242. b = append(b, s[i])
  243. }
  244. for j := len(symbol) - 1; j >= 0; j-- {
  245. b = append(b, symbol[j])
  246. }
  247. if num < 0 {
  248. b = append(b, id.minus[0])
  249. }
  250. // reverse
  251. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  252. b[i], b[j] = b[j], b[i]
  253. }
  254. if int(v) < 2 {
  255. if v == 0 {
  256. b = append(b, id.decimal...)
  257. }
  258. for i := 0; i < 2-int(v); i++ {
  259. b = append(b, '0')
  260. }
  261. }
  262. return string(b)
  263. }
  264. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'id_ID'
  265. // in accounting notation.
  266. func (id *id_ID) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  267. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  268. symbol := id.currencies[currency]
  269. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  270. count := 0
  271. inWhole := v == 0
  272. b := make([]byte, 0, l)
  273. for i := len(s) - 1; i >= 0; i-- {
  274. if s[i] == '.' {
  275. b = append(b, id.decimal[0])
  276. inWhole = true
  277. continue
  278. }
  279. if inWhole {
  280. if count == 3 {
  281. b = append(b, id.group[0])
  282. count = 1
  283. } else {
  284. count++
  285. }
  286. }
  287. b = append(b, s[i])
  288. }
  289. if num < 0 {
  290. for j := len(symbol) - 1; j >= 0; j-- {
  291. b = append(b, symbol[j])
  292. }
  293. b = append(b, id.minus[0])
  294. } else {
  295. for j := len(symbol) - 1; j >= 0; j-- {
  296. b = append(b, symbol[j])
  297. }
  298. }
  299. // reverse
  300. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  301. b[i], b[j] = b[j], b[i]
  302. }
  303. if int(v) < 2 {
  304. if v == 0 {
  305. b = append(b, id.decimal...)
  306. }
  307. for i := 0; i < 2-int(v); i++ {
  308. b = append(b, '0')
  309. }
  310. }
  311. return string(b)
  312. }
  313. // FmtDateShort returns the short date representation of 't' for 'id_ID'
  314. func (id *id_ID) FmtDateShort(t time.Time) string {
  315. b := make([]byte, 0, 32)
  316. if t.Day() < 10 {
  317. b = append(b, '0')
  318. }
  319. b = strconv.AppendInt(b, int64(t.Day()), 10)
  320. b = append(b, []byte{0x2f}...)
  321. if t.Month() < 10 {
  322. b = append(b, '0')
  323. }
  324. b = strconv.AppendInt(b, int64(t.Month()), 10)
  325. b = append(b, []byte{0x2f}...)
  326. if t.Year() > 9 {
  327. b = append(b, strconv.Itoa(t.Year())[2:]...)
  328. } else {
  329. b = append(b, strconv.Itoa(t.Year())[1:]...)
  330. }
  331. return string(b)
  332. }
  333. // FmtDateMedium returns the medium date representation of 't' for 'id_ID'
  334. func (id *id_ID) FmtDateMedium(t time.Time) string {
  335. b := make([]byte, 0, 32)
  336. b = strconv.AppendInt(b, int64(t.Day()), 10)
  337. b = append(b, []byte{0x20}...)
  338. b = append(b, id.monthsAbbreviated[t.Month()]...)
  339. b = append(b, []byte{0x20}...)
  340. if t.Year() > 0 {
  341. b = strconv.AppendInt(b, int64(t.Year()), 10)
  342. } else {
  343. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  344. }
  345. return string(b)
  346. }
  347. // FmtDateLong returns the long date representation of 't' for 'id_ID'
  348. func (id *id_ID) FmtDateLong(t time.Time) string {
  349. b := make([]byte, 0, 32)
  350. b = strconv.AppendInt(b, int64(t.Day()), 10)
  351. b = append(b, []byte{0x20}...)
  352. b = append(b, id.monthsWide[t.Month()]...)
  353. b = append(b, []byte{0x20}...)
  354. if t.Year() > 0 {
  355. b = strconv.AppendInt(b, int64(t.Year()), 10)
  356. } else {
  357. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  358. }
  359. return string(b)
  360. }
  361. // FmtDateFull returns the full date representation of 't' for 'id_ID'
  362. func (id *id_ID) FmtDateFull(t time.Time) string {
  363. b := make([]byte, 0, 32)
  364. b = append(b, id.daysWide[t.Weekday()]...)
  365. b = append(b, []byte{0x2c, 0x20}...)
  366. if t.Day() < 10 {
  367. b = append(b, '0')
  368. }
  369. b = strconv.AppendInt(b, int64(t.Day()), 10)
  370. b = append(b, []byte{0x20}...)
  371. b = append(b, id.monthsWide[t.Month()]...)
  372. b = append(b, []byte{0x20}...)
  373. if t.Year() > 0 {
  374. b = strconv.AppendInt(b, int64(t.Year()), 10)
  375. } else {
  376. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  377. }
  378. return string(b)
  379. }
  380. // FmtTimeShort returns the short time representation of 't' for 'id_ID'
  381. func (id *id_ID) FmtTimeShort(t time.Time) string {
  382. b := make([]byte, 0, 32)
  383. if t.Hour() < 10 {
  384. b = append(b, '0')
  385. }
  386. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  387. b = append(b, []byte{0x2e}...)
  388. if t.Minute() < 10 {
  389. b = append(b, '0')
  390. }
  391. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  392. return string(b)
  393. }
  394. // FmtTimeMedium returns the medium time representation of 't' for 'id_ID'
  395. func (id *id_ID) FmtTimeMedium(t time.Time) string {
  396. b := make([]byte, 0, 32)
  397. if t.Hour() < 10 {
  398. b = append(b, '0')
  399. }
  400. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  401. b = append(b, []byte{0x2e}...)
  402. if t.Minute() < 10 {
  403. b = append(b, '0')
  404. }
  405. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  406. b = append(b, []byte{0x2e}...)
  407. if t.Second() < 10 {
  408. b = append(b, '0')
  409. }
  410. b = strconv.AppendInt(b, int64(t.Second()), 10)
  411. return string(b)
  412. }
  413. // FmtTimeLong returns the long time representation of 't' for 'id_ID'
  414. func (id *id_ID) FmtTimeLong(t time.Time) string {
  415. b := make([]byte, 0, 32)
  416. if t.Hour() < 10 {
  417. b = append(b, '0')
  418. }
  419. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  420. b = append(b, []byte{0x2e}...)
  421. if t.Minute() < 10 {
  422. b = append(b, '0')
  423. }
  424. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  425. b = append(b, []byte{0x2e}...)
  426. if t.Second() < 10 {
  427. b = append(b, '0')
  428. }
  429. b = strconv.AppendInt(b, int64(t.Second()), 10)
  430. b = append(b, []byte{0x20}...)
  431. tz, _ := t.Zone()
  432. b = append(b, tz...)
  433. return string(b)
  434. }
  435. // FmtTimeFull returns the full time representation of 't' for 'id_ID'
  436. func (id *id_ID) FmtTimeFull(t time.Time) string {
  437. b := make([]byte, 0, 32)
  438. if t.Hour() < 10 {
  439. b = append(b, '0')
  440. }
  441. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  442. b = append(b, []byte{0x2e}...)
  443. if t.Minute() < 10 {
  444. b = append(b, '0')
  445. }
  446. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  447. b = append(b, []byte{0x2e}...)
  448. if t.Second() < 10 {
  449. b = append(b, '0')
  450. }
  451. b = strconv.AppendInt(b, int64(t.Second()), 10)
  452. b = append(b, []byte{0x20}...)
  453. tz, _ := t.Zone()
  454. if btz, ok := id.timezones[tz]; ok {
  455. b = append(b, btz...)
  456. } else {
  457. b = append(b, tz...)
  458. }
  459. return string(b)
  460. }