hr_BA.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. package hr_BA
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type hr_BA 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. currencyPositiveSuffix 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 'hr_BA' locale
  41. func New() locales.Translator {
  42. return &hr_BA{
  43. locale: "hr_BA",
  44. pluralsCardinal: []locales.PluralRule{2, 4, 6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: []locales.PluralRule{2, 4, 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 ", "KM", "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 "},
  55. currencyPositiveSuffix: " ",
  56. currencyNegativeSuffix: " ",
  57. monthsAbbreviated: []string{"", "sij", "velj", "ožu", "tra", "svi", "lip", "srp", "kol", "ruj", "lis", "stu", "pro"},
  58. monthsNarrow: []string{"", "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.", "11.", "12."},
  59. monthsWide: []string{"", "siječnja", "veljače", "ožujka", "travnja", "svibnja", "lipnja", "srpnja", "kolovoza", "rujna", "listopada", "studenoga", "prosinca"},
  60. daysAbbreviated: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"},
  61. daysNarrow: []string{"N", "P", "U", "S", "Č", "P", "S"},
  62. daysShort: []string{"ned", "pon", "uto", "sri", "čet", "pet", "sub"},
  63. daysWide: []string{"nedjelja", "ponedjeljak", "utorak", "srijeda", "četvrtak", "petak", "subota"},
  64. periodsAbbreviated: []string{"AM", "PM"},
  65. periodsNarrow: []string{"AM", "PM"},
  66. periodsWide: []string{"AM", "PM"},
  67. erasAbbreviated: []string{"pr. Kr.", "p. Kr."},
  68. erasNarrow: []string{"pr.n.e.", "AD"},
  69. erasWide: []string{"prije Krista", "poslije Krista"},
  70. timezones: map[string]string{"IST": "indijsko vrijeme", "NZDT": "novozelandsko ljetno vrijeme", "BOT": "bolivijsko vrijeme", "CST": "središnje standardno vrijeme", "AEDT": "istočnoaustralsko ljetno vrijeme", "SGT": "singapursko vrijeme", "LHST": "standardno vrijeme otoka Lord Howe", "PST": "pacifičko standardno vrijeme", "MEZ": "srednjoeuropsko standardno vrijeme", "MST": "planinsko standardno vrijeme", "WARST": "zapadno-argentinsko ljetno vrijeme", "WIB": "zapadnoindonezijsko vrijeme", "OEZ": "istočnoeuropsko standardno vrijeme", "AWST": "zapadnoaustralsko standardno vrijeme", "AKST": "aljaško standardno vrijeme", "WEZ": "zapadnoeuropsko standardno vrijeme", "WITA": "srednjoindonezijsko vrijeme", "WESZ": "zapadnoeuropsko ljetno vrijeme", "ACWST": "australsko središnje zapadno standardno vrijeme", "ACDT": "srednjoaustralsko ljetno vrijeme", "CAT": "srednjoafričko vrijeme", "GFT": "vrijeme Francuske Gvajane", "ADT": "atlantsko ljetno vrijeme", "HAT": "newfoundlandsko ljetno vrijeme", "COST": "kolumbijsko ljetno vrijeme", "∅∅∅": "brazilijsko ljetno vrijeme", "CHAST": "standardno vrijeme Chathama", "HKT": "hongkonško standardno vrijeme", "TMST": "turkmenistansko ljetno vrijeme", "AEST": "istočnoaustralsko standardno vrijeme", "ACWDT": "australsko središnje zapadno ljetno vrijeme", "HKST": "hongkonško ljetno vrijeme", "WAST": "zapadnoafričko ljetno vrijeme", "EAT": "istočnoafričko vrijeme", "PDT": "pacifičko ljetno vrijeme", "MESZ": "srednjoeuropsko ljetno vrijeme", "CLT": "čileansko standardno vrijeme", "BT": "butansko vrijeme", "SAST": "južnoafričko vrijeme", "ARST": "argentinsko ljetno vrijeme", "NZST": "novozelandsko standardno vrijeme", "UYT": "urugvajsko standardno vrijeme", "UYST": "urugvajsko ljetno vrijeme", "ChST": "standardno vrijeme Chamorra", "COT": "kolumbijsko standardno vrijeme", "WAT": "zapadnoafričko standardno vrijeme", "LHDT": "ljetno vrijeme otoka Lord Howe", "MYT": "malezijsko vrijeme", "JST": "japansko standardno vrijeme", "JDT": "japansko ljetno vrijeme", "CDT": "središnje ljetno vrijeme", "CHADT": "ljetno vrijeme Chathama", "VET": "venezuelsko vrijeme", "OESZ": "istočnoeuropsko ljetno vrijeme", "ART": "argentinsko standardno vrijeme", "TMT": "turkmenistansko standardno vrijeme", "GYT": "gvajansko vrijeme", "HNT": "newfoundlandsko standardno vrijeme", "WIT": "istočnoindonezijsko vrijeme", "MDT": "planinsko ljetno vrijeme", "HADT": "havajsko-aleutsko ljetno vrijeme", "EST": "istočno standardno vrijeme", "HAST": "havajsko-aleutsko standardno vrijeme", "WART": "zapadno-argentinsko standardno vrijeme", "ACST": "srednjoaustralsko standardno vrijeme", "AWDT": "zapadnoaustralsko ljetno vrijeme", "SRT": "surinamsko vrijeme", "CLST": "čileansko ljetno vrijeme", "ECT": "ekvadorsko vrijeme", "AKDT": "aljaško ljetno vrijeme", "GMT": "univerzalno vrijeme", "EDT": "istočno ljetno vrijeme", "AST": "atlantsko standardno vrijeme"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (hr *hr_BA) Locale() string {
  75. return hr.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'hr_BA'
  78. func (hr *hr_BA) PluralsCardinal() []locales.PluralRule {
  79. return hr.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'hr_BA'
  82. func (hr *hr_BA) PluralsOrdinal() []locales.PluralRule {
  83. return hr.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'hr_BA'
  86. func (hr *hr_BA) PluralsRange() []locales.PluralRule {
  87. return hr.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'hr_BA'
  90. func (hr *hr_BA) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. i := int64(n)
  93. f := locales.F(n, v)
  94. iMod10 := i % 10
  95. iMod100 := i % 100
  96. fMod10 := f % 10
  97. fMod100 := f % 100
  98. if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
  99. return locales.PluralRuleOne
  100. } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && iMod100 < 12 && iMod100 > 14) || (fMod10 >= 2 && fMod10 <= 4 && fMod100 < 12 && fMod100 > 14) {
  101. return locales.PluralRuleFew
  102. }
  103. return locales.PluralRuleOther
  104. }
  105. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'hr_BA'
  106. func (hr *hr_BA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  107. return locales.PluralRuleOther
  108. }
  109. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'hr_BA'
  110. func (hr *hr_BA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  111. start := hr.CardinalPluralRule(num1, v1)
  112. end := hr.CardinalPluralRule(num2, v2)
  113. if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
  114. return locales.PluralRuleOne
  115. } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
  116. return locales.PluralRuleFew
  117. } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  118. return locales.PluralRuleOther
  119. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
  120. return locales.PluralRuleOne
  121. } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
  122. return locales.PluralRuleFew
  123. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
  124. return locales.PluralRuleOther
  125. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  126. return locales.PluralRuleOne
  127. } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
  128. return locales.PluralRuleFew
  129. }
  130. return locales.PluralRuleOther
  131. }
  132. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  133. func (hr *hr_BA) MonthAbbreviated(month time.Month) string {
  134. return hr.monthsAbbreviated[month]
  135. }
  136. // MonthsAbbreviated returns the locales abbreviated months
  137. func (hr *hr_BA) MonthsAbbreviated() []string {
  138. return hr.monthsAbbreviated[1:]
  139. }
  140. // MonthNarrow returns the locales narrow month given the 'month' provided
  141. func (hr *hr_BA) MonthNarrow(month time.Month) string {
  142. return hr.monthsNarrow[month]
  143. }
  144. // MonthsNarrow returns the locales narrow months
  145. func (hr *hr_BA) MonthsNarrow() []string {
  146. return hr.monthsNarrow[1:]
  147. }
  148. // MonthWide returns the locales wide month given the 'month' provided
  149. func (hr *hr_BA) MonthWide(month time.Month) string {
  150. return hr.monthsWide[month]
  151. }
  152. // MonthsWide returns the locales wide months
  153. func (hr *hr_BA) MonthsWide() []string {
  154. return hr.monthsWide[1:]
  155. }
  156. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  157. func (hr *hr_BA) WeekdayAbbreviated(weekday time.Weekday) string {
  158. return hr.daysAbbreviated[weekday]
  159. }
  160. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  161. func (hr *hr_BA) WeekdaysAbbreviated() []string {
  162. return hr.daysAbbreviated
  163. }
  164. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  165. func (hr *hr_BA) WeekdayNarrow(weekday time.Weekday) string {
  166. return hr.daysNarrow[weekday]
  167. }
  168. // WeekdaysNarrow returns the locales narrow weekdays
  169. func (hr *hr_BA) WeekdaysNarrow() []string {
  170. return hr.daysNarrow
  171. }
  172. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  173. func (hr *hr_BA) WeekdayShort(weekday time.Weekday) string {
  174. return hr.daysShort[weekday]
  175. }
  176. // WeekdaysShort returns the locales short weekdays
  177. func (hr *hr_BA) WeekdaysShort() []string {
  178. return hr.daysShort
  179. }
  180. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  181. func (hr *hr_BA) WeekdayWide(weekday time.Weekday) string {
  182. return hr.daysWide[weekday]
  183. }
  184. // WeekdaysWide returns the locales wide weekdays
  185. func (hr *hr_BA) WeekdaysWide() []string {
  186. return hr.daysWide
  187. }
  188. // FmtNumber returns 'num' with digits/precision of 'v' for 'hr_BA' and handles both Whole and Real numbers based on 'v'
  189. func (hr *hr_BA) FmtNumber(num float64, v uint64) string {
  190. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  191. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  192. count := 0
  193. inWhole := v == 0
  194. b := make([]byte, 0, l)
  195. for i := len(s) - 1; i >= 0; i-- {
  196. if s[i] == '.' {
  197. b = append(b, hr.decimal[0])
  198. inWhole = true
  199. continue
  200. }
  201. if inWhole {
  202. if count == 3 {
  203. b = append(b, hr.group[0])
  204. count = 1
  205. } else {
  206. count++
  207. }
  208. }
  209. b = append(b, s[i])
  210. }
  211. if num < 0 {
  212. b = append(b, hr.minus[0])
  213. }
  214. // reverse
  215. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  216. b[i], b[j] = b[j], b[i]
  217. }
  218. return string(b)
  219. }
  220. // FmtPercent returns 'num' with digits/precision of 'v' for 'hr_BA' and handles both Whole and Real numbers based on 'v'
  221. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  222. func (hr *hr_BA) FmtPercent(num float64, v uint64) string {
  223. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  224. l := len(s) + 3
  225. b := make([]byte, 0, l)
  226. for i := len(s) - 1; i >= 0; i-- {
  227. if s[i] == '.' {
  228. b = append(b, hr.decimal[0])
  229. continue
  230. }
  231. b = append(b, s[i])
  232. }
  233. if num < 0 {
  234. b = append(b, hr.minus[0])
  235. }
  236. // reverse
  237. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  238. b[i], b[j] = b[j], b[i]
  239. }
  240. b = append(b, hr.percent...)
  241. return string(b)
  242. }
  243. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'hr_BA'
  244. func (hr *hr_BA) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  245. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  246. symbol := hr.currencies[currency]
  247. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  248. count := 0
  249. inWhole := v == 0
  250. b := make([]byte, 0, l)
  251. for i := len(s) - 1; i >= 0; i-- {
  252. if s[i] == '.' {
  253. b = append(b, hr.decimal[0])
  254. inWhole = true
  255. continue
  256. }
  257. if inWhole {
  258. if count == 3 {
  259. b = append(b, hr.group[0])
  260. count = 1
  261. } else {
  262. count++
  263. }
  264. }
  265. b = append(b, s[i])
  266. }
  267. if num < 0 {
  268. b = append(b, hr.minus[0])
  269. }
  270. // reverse
  271. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  272. b[i], b[j] = b[j], b[i]
  273. }
  274. if int(v) < 2 {
  275. if v == 0 {
  276. b = append(b, hr.decimal...)
  277. }
  278. for i := 0; i < 2-int(v); i++ {
  279. b = append(b, '0')
  280. }
  281. }
  282. b = append(b, hr.currencyPositiveSuffix...)
  283. b = append(b, symbol...)
  284. return string(b)
  285. }
  286. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'hr_BA'
  287. // in accounting notation.
  288. func (hr *hr_BA) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  289. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  290. symbol := hr.currencies[currency]
  291. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  292. count := 0
  293. inWhole := v == 0
  294. b := make([]byte, 0, l)
  295. for i := len(s) - 1; i >= 0; i-- {
  296. if s[i] == '.' {
  297. b = append(b, hr.decimal[0])
  298. inWhole = true
  299. continue
  300. }
  301. if inWhole {
  302. if count == 3 {
  303. b = append(b, hr.group[0])
  304. count = 1
  305. } else {
  306. count++
  307. }
  308. }
  309. b = append(b, s[i])
  310. }
  311. if num < 0 {
  312. b = append(b, hr.minus[0])
  313. }
  314. // reverse
  315. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  316. b[i], b[j] = b[j], b[i]
  317. }
  318. if int(v) < 2 {
  319. if v == 0 {
  320. b = append(b, hr.decimal...)
  321. }
  322. for i := 0; i < 2-int(v); i++ {
  323. b = append(b, '0')
  324. }
  325. }
  326. if num < 0 {
  327. b = append(b, hr.currencyNegativeSuffix...)
  328. b = append(b, symbol...)
  329. } else {
  330. b = append(b, hr.currencyPositiveSuffix...)
  331. b = append(b, symbol...)
  332. }
  333. return string(b)
  334. }
  335. // FmtDateShort returns the short date representation of 't' for 'hr_BA'
  336. func (hr *hr_BA) FmtDateShort(t time.Time) string {
  337. b := make([]byte, 0, 32)
  338. if t.Day() < 10 {
  339. b = append(b, '0')
  340. }
  341. b = strconv.AppendInt(b, int64(t.Day()), 10)
  342. b = append(b, []byte{0x2e}...)
  343. if t.Month() < 10 {
  344. b = append(b, '0')
  345. }
  346. b = strconv.AppendInt(b, int64(t.Month()), 10)
  347. b = append(b, []byte{0x2e}...)
  348. b = strconv.AppendInt(b, int64(t.Year()), 10)
  349. b = append(b, []byte{0x2e}...)
  350. return string(b)
  351. }
  352. // FmtDateMedium returns the medium date representation of 't' for 'hr_BA'
  353. func (hr *hr_BA) FmtDateMedium(t time.Time) string {
  354. b := make([]byte, 0, 32)
  355. b = strconv.AppendInt(b, int64(t.Day()), 10)
  356. b = append(b, []byte{0x2e, 0x20}...)
  357. b = append(b, hr.monthsAbbreviated[t.Month()]...)
  358. b = append(b, []byte{0x20}...)
  359. b = strconv.AppendInt(b, int64(t.Year()), 10)
  360. b = append(b, []byte{0x2e}...)
  361. return string(b)
  362. }
  363. // FmtDateLong returns the long date representation of 't' for 'hr_BA'
  364. func (hr *hr_BA) FmtDateLong(t time.Time) string {
  365. b := make([]byte, 0, 32)
  366. b = strconv.AppendInt(b, int64(t.Day()), 10)
  367. b = append(b, []byte{0x2e, 0x20}...)
  368. b = append(b, hr.monthsWide[t.Month()]...)
  369. b = append(b, []byte{0x20}...)
  370. b = strconv.AppendInt(b, int64(t.Year()), 10)
  371. b = append(b, []byte{0x2e}...)
  372. return string(b)
  373. }
  374. // FmtDateFull returns the full date representation of 't' for 'hr_BA'
  375. func (hr *hr_BA) FmtDateFull(t time.Time) string {
  376. b := make([]byte, 0, 32)
  377. b = append(b, hr.daysWide[t.Weekday()]...)
  378. b = append(b, []byte{0x2c, 0x20}...)
  379. b = strconv.AppendInt(b, int64(t.Day()), 10)
  380. b = append(b, []byte{0x2e, 0x20}...)
  381. b = append(b, hr.monthsWide[t.Month()]...)
  382. b = append(b, []byte{0x20}...)
  383. b = strconv.AppendInt(b, int64(t.Year()), 10)
  384. b = append(b, []byte{0x2e}...)
  385. return string(b)
  386. }
  387. // FmtTimeShort returns the short time representation of 't' for 'hr_BA'
  388. func (hr *hr_BA) FmtTimeShort(t time.Time) string {
  389. b := make([]byte, 0, 32)
  390. if t.Hour() < 10 {
  391. b = append(b, '0')
  392. }
  393. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  394. b = append(b, hr.timeSeparator...)
  395. if t.Minute() < 10 {
  396. b = append(b, '0')
  397. }
  398. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  399. return string(b)
  400. }
  401. // FmtTimeMedium returns the medium time representation of 't' for 'hr_BA'
  402. func (hr *hr_BA) FmtTimeMedium(t time.Time) string {
  403. b := make([]byte, 0, 32)
  404. if t.Hour() < 10 {
  405. b = append(b, '0')
  406. }
  407. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  408. b = append(b, hr.timeSeparator...)
  409. if t.Minute() < 10 {
  410. b = append(b, '0')
  411. }
  412. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  413. b = append(b, hr.timeSeparator...)
  414. if t.Second() < 10 {
  415. b = append(b, '0')
  416. }
  417. b = strconv.AppendInt(b, int64(t.Second()), 10)
  418. return string(b)
  419. }
  420. // FmtTimeLong returns the long time representation of 't' for 'hr_BA'
  421. func (hr *hr_BA) FmtTimeLong(t time.Time) string {
  422. b := make([]byte, 0, 32)
  423. if t.Hour() < 10 {
  424. b = append(b, '0')
  425. }
  426. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  427. b = append(b, hr.timeSeparator...)
  428. if t.Minute() < 10 {
  429. b = append(b, '0')
  430. }
  431. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  432. b = append(b, hr.timeSeparator...)
  433. if t.Second() < 10 {
  434. b = append(b, '0')
  435. }
  436. b = strconv.AppendInt(b, int64(t.Second()), 10)
  437. b = append(b, []byte{0x20}...)
  438. tz, _ := t.Zone()
  439. b = append(b, tz...)
  440. return string(b)
  441. }
  442. // FmtTimeFull returns the full time representation of 't' for 'hr_BA'
  443. func (hr *hr_BA) FmtTimeFull(t time.Time) string {
  444. b := make([]byte, 0, 32)
  445. if t.Hour() < 10 {
  446. b = append(b, '0')
  447. }
  448. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  449. b = append(b, hr.timeSeparator...)
  450. if t.Minute() < 10 {
  451. b = append(b, '0')
  452. }
  453. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  454. b = append(b, hr.timeSeparator...)
  455. if t.Second() < 10 {
  456. b = append(b, '0')
  457. }
  458. b = strconv.AppendInt(b, int64(t.Second()), 10)
  459. b = append(b, []byte{0x20}...)
  460. tz, _ := t.Zone()
  461. if btz, ok := hr.timezones[tz]; ok {
  462. b = append(b, btz...)
  463. } else {
  464. b = append(b, tz...)
  465. }
  466. return string(b)
  467. }