brx_IN.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. package brx_IN
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type brx_IN 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. currencyPositivePrefix string
  23. currencyNegativePrefix 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 'brx_IN' locale
  41. func New() locales.Translator {
  42. return &brx_IN{
  43. locale: "brx_IN",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: nil,
  46. pluralsRange: nil,
  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", "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"},
  55. currencyPositivePrefix: " ",
  56. currencyNegativePrefix: " ",
  57. monthsNarrow: []string{"", "ज", "फे", "मा", "ए", "मे", "जु", "जु", "आ", "से", "अ", "न", "दि"},
  58. monthsWide: []string{"", "जानुवारी", "फेब्रुवारी", "मार्स", "एफ्रिल", "मे", "जुन", "जुलाइ", "आगस्थ", "सेबथेज्ब़र", "अखथबर", "नबेज्ब़र", "दिसेज्ब़र"},
  59. daysAbbreviated: []string{"रबि", "सम", "मंगल", "बुद", "बिसथि", "सुखुर", "सुनि"},
  60. daysNarrow: []string{"र", "स", "मं", "बु", "बि", "सु", "सु"},
  61. daysWide: []string{"रबिबार", "समबार", "मंगलबार", "बुदबार", "बिसथिबार", "सुखुरबार", "सुनिबार"},
  62. periodsAbbreviated: []string{"फुं", "बेलासे"},
  63. periodsWide: []string{"फुं", "बेलासे"},
  64. erasAbbreviated: []string{"ईसा.पूर्व", "सन"},
  65. erasNarrow: []string{"", ""},
  66. erasWide: []string{"", ""},
  67. timezones: map[string]string{"MDT": "माकाऊ समर टाईम", "WIT": "ईस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "COST": "कोलंबिया समर टाईम", "PDT": "पैसीफीक डेलाईट टाईम", "SAST": "दक्षिण अफ्रीका स्टैंडर्ड टाईम", "JST": "जपान स्टैंडर्ड टाईम", "AKDT": "अलास्का डेलाईट टाईम", "VET": "वेनेज़ुएला स्टैंडर्ड टाईम", "ACST": "मध्य ओस्ट्रेलिया स्टैंडर्ड टाईम", "WARST": "पश्चीम अर्जण्टिना समर टाईम", "HAT": "न्युफाऊंडलैण्ड डेलाईट टाईम", "HAST": "हवाई आलटन स्टैंडर्ड टाईम", "AWDT": "दक्षिण ओस्ट्रेलिया डेलाईट टाईम", "ACDT": "मध्य ओस्ट्रेलिया डेलाईट टाईम", "ACWDT": "मध्य-पश्चीम ओस्ट्रेलिया डेलाईट टाईम", "LHDT": "लार्ड़ होव डेलाईट टाईम", "HEPM": "सेँ पीयॅर एवं मीकलों डेलाईट टाईम", "HADT": "हवाई आलटन डेलाईट टाईम", "ChST": "चामरो स्टैंडर्ड टाईम", "CST": "सैंट्रल अमरिका स्टैंडर्ड टाईम", "WAST": "पश्चीम अफ्रीका समर टाईम", "EST": "ईस्टर्न अमरिका स्टैंडर्ड टाईम", "HNT": "न्युफाऊंडलैण्ड स्टैंडर्ड टाईम", "AST": "अटलांटीक स्टैंडर्ड टाईम", "ACWST": "मध्य-पश्चीम ओस्ट्रेलिया स्टैंडर्ड टाईम", "HNOG": "ग्रीनलैण्ड वेस्टर्न स्टैंडर्ड टाईम", "HKT": "हाँगकॉंग स्टैंडर्ड टाईम", "IST": "भारतीय स्टैंडर्ड टाईम", "MST": "माकाऊ स्टैंडर्ड टाईम", "OESZ": "ईस्टर्न यूरोप समर टाईम", "HECU": "क्युबा डेलाईट टाईम", "AEST": "पूर्वी ओस्ट्रेलिया स्टैंडर्ड टाईम", "GFT": "फ्रान्सीसी गुयाना स्टैंडर्ड टाईम", "HKST": "हाँगकॉंग समर टाईम", "∅∅∅": "पेरु समर टाईम", "AEDT": "पूर्वी ओस्ट्रेलिया डेलाईट टाईम", "WESZ": "वेस्टर्न यूरोप समर टाईम", "MEZ": "मध्य यूरोप स्टैंडर्ड टाईम", "COT": "कोलंबिया स्टैंडर्ड टाईम", "WITA": "ईंडोनीशिया स्टैंडर्ड टाईम", "CLT": "चीली स्टैंडर्ड टाईम", "JDT": "जपान डेलाईट टाईम", "LHST": "लार्ड़ होव स्टैंडर्ड टाईम", "ARST": "अर्जण्टिना समर टाईम", "UYST": "ऊरुगुए समर टाईम", "AKST": "अलास्का स्टैंडर्ड टाईम", "EAT": "पूर्वी अफ्रीका स्टैंडर्ड टाईम", "BT": "भुटान स्टैंडर्ड टाईम", "CLST": "चीली समर टाईम", "HEPMX": "HEPMX", "SRT": "सुरीनाम स्टैंडर्ड टाईम", "EDT": "ईस्टर्न अमरिका डेलाईट टाईम", "MESZ": "मध्य यूरोप समर टाईम", "ART": "अर्जनटिना स्टैंडर्ड टाईम", "UYT": "ऊरुगुए स्टैंडर्ड टाईम", "CHAST": "चैथम स्टैंडर्ड टाईम", "AWST": "दक्षिण ओस्ट्रेलिया स्टैंडर्ड टाईम", "WART": "पश्चीम अर्जण्टिना स्टैंडर्ड टाईम", "TMT": "तुर्कमेनीस्तान स्टैंडर्ड टाईम", "PST": "पैसीफीक स्टैंडर्ड टाईम", "NZDT": "न्युज़ीलैण्ड डेलाईट टाईम", "ECT": "एक्वाडौर स्टैंडर्ड टाईम", "HNNOMX": "HNNOMX", "OEZ": "ईस्टर्न यूरोप स्टैंडर्ड टाईम", "HNCU": "क्युबा स्टैंडर्ड टाईम", "HNPMX": "HNPMX", "ADT": "अटलांटीक डेलाईट टाईम", "MYT": "मलेशिया स्टैंडर्ड टाईम", "HENOMX": "HENOMX", "TMST": "तुर्कमेनीस्तान समर टाईम", "GYT": "गुयाना स्टैंडर्ड टाईम", "CDT": "सैंट्रल अमरिका डेलाईट टाईम", "WAT": "पश्चीम अफ्रीका स्टैंडर्ड टाईम", "BOT": "बोलिविया स्टैंडर्ड टाईम", "HEEG": "ग्रीनलैण्ड ईस्टर्न समर टाईम", "HEOG": "ग्रीनलैण्ड वेस्टर्न समर टाईम", "CAT": "मध्य अफ्रीका स्टैंडर्ड टाईम", "GMT": "ग्रीनीच स्टैंडर्ड टाईम", "CHADT": "चैथम डेलाईट टाईम", "WEZ": "वेस्टर्न यूरोप स्टैंडर्ड टाईम", "WIB": "वेस्टर्न ईंडोनीशिया स्टैंडर्ड टाईम", "NZST": "न्युज़ीलैण्ड स्टैंडर्ड टाईम", "SGT": "सींगापुर स्टैंडर्ड टाईम", "HNEG": "ग्रीनलैण्ड ईस्टर्न स्टैंडर्ड टाईम", "HNPM": "सेँ पीयॅर एवं मीकलों स्टैंडर्ड टाईम"},
  68. }
  69. }
  70. // Locale returns the current translators string locale
  71. func (brx *brx_IN) Locale() string {
  72. return brx.locale
  73. }
  74. // PluralsCardinal returns the list of cardinal plural rules associated with 'brx_IN'
  75. func (brx *brx_IN) PluralsCardinal() []locales.PluralRule {
  76. return brx.pluralsCardinal
  77. }
  78. // PluralsOrdinal returns the list of ordinal plural rules associated with 'brx_IN'
  79. func (brx *brx_IN) PluralsOrdinal() []locales.PluralRule {
  80. return brx.pluralsOrdinal
  81. }
  82. // PluralsRange returns the list of range plural rules associated with 'brx_IN'
  83. func (brx *brx_IN) PluralsRange() []locales.PluralRule {
  84. return brx.pluralsRange
  85. }
  86. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'brx_IN'
  87. func (brx *brx_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  88. n := math.Abs(num)
  89. if n == 1 {
  90. return locales.PluralRuleOne
  91. }
  92. return locales.PluralRuleOther
  93. }
  94. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'brx_IN'
  95. func (brx *brx_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  96. return locales.PluralRuleUnknown
  97. }
  98. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'brx_IN'
  99. func (brx *brx_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  100. return locales.PluralRuleUnknown
  101. }
  102. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  103. func (brx *brx_IN) MonthAbbreviated(month time.Month) string {
  104. return brx.monthsAbbreviated[month]
  105. }
  106. // MonthsAbbreviated returns the locales abbreviated months
  107. func (brx *brx_IN) MonthsAbbreviated() []string {
  108. return nil
  109. }
  110. // MonthNarrow returns the locales narrow month given the 'month' provided
  111. func (brx *brx_IN) MonthNarrow(month time.Month) string {
  112. return brx.monthsNarrow[month]
  113. }
  114. // MonthsNarrow returns the locales narrow months
  115. func (brx *brx_IN) MonthsNarrow() []string {
  116. return brx.monthsNarrow[1:]
  117. }
  118. // MonthWide returns the locales wide month given the 'month' provided
  119. func (brx *brx_IN) MonthWide(month time.Month) string {
  120. return brx.monthsWide[month]
  121. }
  122. // MonthsWide returns the locales wide months
  123. func (brx *brx_IN) MonthsWide() []string {
  124. return brx.monthsWide[1:]
  125. }
  126. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  127. func (brx *brx_IN) WeekdayAbbreviated(weekday time.Weekday) string {
  128. return brx.daysAbbreviated[weekday]
  129. }
  130. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  131. func (brx *brx_IN) WeekdaysAbbreviated() []string {
  132. return brx.daysAbbreviated
  133. }
  134. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  135. func (brx *brx_IN) WeekdayNarrow(weekday time.Weekday) string {
  136. return brx.daysNarrow[weekday]
  137. }
  138. // WeekdaysNarrow returns the locales narrow weekdays
  139. func (brx *brx_IN) WeekdaysNarrow() []string {
  140. return brx.daysNarrow
  141. }
  142. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  143. func (brx *brx_IN) WeekdayShort(weekday time.Weekday) string {
  144. return brx.daysShort[weekday]
  145. }
  146. // WeekdaysShort returns the locales short weekdays
  147. func (brx *brx_IN) WeekdaysShort() []string {
  148. return brx.daysShort
  149. }
  150. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  151. func (brx *brx_IN) WeekdayWide(weekday time.Weekday) string {
  152. return brx.daysWide[weekday]
  153. }
  154. // WeekdaysWide returns the locales wide weekdays
  155. func (brx *brx_IN) WeekdaysWide() []string {
  156. return brx.daysWide
  157. }
  158. // Decimal returns the decimal point of number
  159. func (brx *brx_IN) Decimal() string {
  160. return brx.decimal
  161. }
  162. // Group returns the group of number
  163. func (brx *brx_IN) Group() string {
  164. return brx.group
  165. }
  166. // Group returns the minus sign of number
  167. func (brx *brx_IN) Minus() string {
  168. return brx.minus
  169. }
  170. // FmtNumber returns 'num' with digits/precision of 'v' for 'brx_IN' and handles both Whole and Real numbers based on 'v'
  171. func (brx *brx_IN) FmtNumber(num float64, v uint64) string {
  172. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  173. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  174. count := 0
  175. inWhole := v == 0
  176. inSecondary := false
  177. groupThreshold := 3
  178. b := make([]byte, 0, l)
  179. for i := len(s) - 1; i >= 0; i-- {
  180. if s[i] == '.' {
  181. b = append(b, brx.decimal[0])
  182. inWhole = true
  183. continue
  184. }
  185. if inWhole {
  186. if count == groupThreshold {
  187. b = append(b, brx.group[0])
  188. count = 1
  189. if !inSecondary {
  190. inSecondary = true
  191. groupThreshold = 2
  192. }
  193. } else {
  194. count++
  195. }
  196. }
  197. b = append(b, s[i])
  198. }
  199. if num < 0 {
  200. b = append(b, brx.minus[0])
  201. }
  202. // reverse
  203. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  204. b[i], b[j] = b[j], b[i]
  205. }
  206. return string(b)
  207. }
  208. // FmtPercent returns 'num' with digits/precision of 'v' for 'brx_IN' and handles both Whole and Real numbers based on 'v'
  209. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  210. func (brx *brx_IN) FmtPercent(num float64, v uint64) string {
  211. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  212. l := len(s) + 3
  213. b := make([]byte, 0, l)
  214. for i := len(s) - 1; i >= 0; i-- {
  215. if s[i] == '.' {
  216. b = append(b, brx.decimal[0])
  217. continue
  218. }
  219. b = append(b, s[i])
  220. }
  221. if num < 0 {
  222. b = append(b, brx.minus[0])
  223. }
  224. // reverse
  225. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  226. b[i], b[j] = b[j], b[i]
  227. }
  228. b = append(b, brx.percent...)
  229. return string(b)
  230. }
  231. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'brx_IN'
  232. func (brx *brx_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  233. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  234. symbol := brx.currencies[currency]
  235. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  236. count := 0
  237. inWhole := v == 0
  238. inSecondary := false
  239. groupThreshold := 3
  240. b := make([]byte, 0, l)
  241. for i := len(s) - 1; i >= 0; i-- {
  242. if s[i] == '.' {
  243. b = append(b, brx.decimal[0])
  244. inWhole = true
  245. continue
  246. }
  247. if inWhole {
  248. if count == groupThreshold {
  249. b = append(b, brx.group[0])
  250. count = 1
  251. if !inSecondary {
  252. inSecondary = true
  253. groupThreshold = 2
  254. }
  255. } else {
  256. count++
  257. }
  258. }
  259. b = append(b, s[i])
  260. }
  261. for j := len(symbol) - 1; j >= 0; j-- {
  262. b = append(b, symbol[j])
  263. }
  264. for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- {
  265. b = append(b, brx.currencyPositivePrefix[j])
  266. }
  267. if num < 0 {
  268. b = append(b, brx.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, brx.decimal...)
  277. }
  278. for i := 0; i < 2-int(v); i++ {
  279. b = append(b, '0')
  280. }
  281. }
  282. return string(b)
  283. }
  284. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'brx_IN'
  285. // in accounting notation.
  286. func (brx *brx_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  287. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  288. symbol := brx.currencies[currency]
  289. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  290. count := 0
  291. inWhole := v == 0
  292. inSecondary := false
  293. groupThreshold := 3
  294. b := make([]byte, 0, l)
  295. for i := len(s) - 1; i >= 0; i-- {
  296. if s[i] == '.' {
  297. b = append(b, brx.decimal[0])
  298. inWhole = true
  299. continue
  300. }
  301. if inWhole {
  302. if count == groupThreshold {
  303. b = append(b, brx.group[0])
  304. count = 1
  305. if !inSecondary {
  306. inSecondary = true
  307. groupThreshold = 2
  308. }
  309. } else {
  310. count++
  311. }
  312. }
  313. b = append(b, s[i])
  314. }
  315. if num < 0 {
  316. for j := len(symbol) - 1; j >= 0; j-- {
  317. b = append(b, symbol[j])
  318. }
  319. for j := len(brx.currencyNegativePrefix) - 1; j >= 0; j-- {
  320. b = append(b, brx.currencyNegativePrefix[j])
  321. }
  322. b = append(b, brx.minus[0])
  323. } else {
  324. for j := len(symbol) - 1; j >= 0; j-- {
  325. b = append(b, symbol[j])
  326. }
  327. for j := len(brx.currencyPositivePrefix) - 1; j >= 0; j-- {
  328. b = append(b, brx.currencyPositivePrefix[j])
  329. }
  330. }
  331. // reverse
  332. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  333. b[i], b[j] = b[j], b[i]
  334. }
  335. if int(v) < 2 {
  336. if v == 0 {
  337. b = append(b, brx.decimal...)
  338. }
  339. for i := 0; i < 2-int(v); i++ {
  340. b = append(b, '0')
  341. }
  342. }
  343. return string(b)
  344. }
  345. // FmtDateShort returns the short date representation of 't' for 'brx_IN'
  346. func (brx *brx_IN) FmtDateShort(t time.Time) string {
  347. b := make([]byte, 0, 32)
  348. b = strconv.AppendInt(b, int64(t.Month()), 10)
  349. b = append(b, []byte{0x2f}...)
  350. b = strconv.AppendInt(b, int64(t.Day()), 10)
  351. b = append(b, []byte{0x2f}...)
  352. if t.Year() > 9 {
  353. b = append(b, strconv.Itoa(t.Year())[2:]...)
  354. } else {
  355. b = append(b, strconv.Itoa(t.Year())[1:]...)
  356. }
  357. return string(b)
  358. }
  359. // FmtDateMedium returns the medium date representation of 't' for 'brx_IN'
  360. func (brx *brx_IN) FmtDateMedium(t time.Time) string {
  361. b := make([]byte, 0, 32)
  362. b = append(b, brx.monthsAbbreviated[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. if t.Year() > 0 {
  367. b = strconv.AppendInt(b, int64(t.Year()), 10)
  368. } else {
  369. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  370. }
  371. return string(b)
  372. }
  373. // FmtDateLong returns the long date representation of 't' for 'brx_IN'
  374. func (brx *brx_IN) FmtDateLong(t time.Time) string {
  375. b := make([]byte, 0, 32)
  376. b = append(b, brx.monthsWide[t.Month()]...)
  377. b = append(b, []byte{0x20}...)
  378. b = strconv.AppendInt(b, int64(t.Day()), 10)
  379. b = append(b, []byte{0x2c, 0x20}...)
  380. if t.Year() > 0 {
  381. b = strconv.AppendInt(b, int64(t.Year()), 10)
  382. } else {
  383. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  384. }
  385. return string(b)
  386. }
  387. // FmtDateFull returns the full date representation of 't' for 'brx_IN'
  388. func (brx *brx_IN) FmtDateFull(t time.Time) string {
  389. b := make([]byte, 0, 32)
  390. b = append(b, brx.daysWide[t.Weekday()]...)
  391. b = append(b, []byte{0x2c, 0x20}...)
  392. b = append(b, brx.monthsWide[t.Month()]...)
  393. b = append(b, []byte{0x20}...)
  394. b = strconv.AppendInt(b, int64(t.Day()), 10)
  395. b = append(b, []byte{0x2c, 0x20}...)
  396. if t.Year() > 0 {
  397. b = strconv.AppendInt(b, int64(t.Year()), 10)
  398. } else {
  399. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  400. }
  401. return string(b)
  402. }
  403. // FmtTimeShort returns the short time representation of 't' for 'brx_IN'
  404. func (brx *brx_IN) FmtTimeShort(t time.Time) string {
  405. b := make([]byte, 0, 32)
  406. h := t.Hour()
  407. if h > 12 {
  408. h -= 12
  409. }
  410. b = strconv.AppendInt(b, int64(h), 10)
  411. b = append(b, brx.timeSeparator...)
  412. if t.Minute() < 10 {
  413. b = append(b, '0')
  414. }
  415. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  416. b = append(b, []byte{0x20}...)
  417. if t.Hour() < 12 {
  418. b = append(b, brx.periodsAbbreviated[0]...)
  419. } else {
  420. b = append(b, brx.periodsAbbreviated[1]...)
  421. }
  422. return string(b)
  423. }
  424. // FmtTimeMedium returns the medium time representation of 't' for 'brx_IN'
  425. func (brx *brx_IN) FmtTimeMedium(t time.Time) string {
  426. b := make([]byte, 0, 32)
  427. h := t.Hour()
  428. if h > 12 {
  429. h -= 12
  430. }
  431. b = strconv.AppendInt(b, int64(h), 10)
  432. b = append(b, brx.timeSeparator...)
  433. if t.Minute() < 10 {
  434. b = append(b, '0')
  435. }
  436. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  437. b = append(b, brx.timeSeparator...)
  438. if t.Second() < 10 {
  439. b = append(b, '0')
  440. }
  441. b = strconv.AppendInt(b, int64(t.Second()), 10)
  442. b = append(b, []byte{0x20}...)
  443. if t.Hour() < 12 {
  444. b = append(b, brx.periodsAbbreviated[0]...)
  445. } else {
  446. b = append(b, brx.periodsAbbreviated[1]...)
  447. }
  448. return string(b)
  449. }
  450. // FmtTimeLong returns the long time representation of 't' for 'brx_IN'
  451. func (brx *brx_IN) FmtTimeLong(t time.Time) string {
  452. b := make([]byte, 0, 32)
  453. h := t.Hour()
  454. if h > 12 {
  455. h -= 12
  456. }
  457. b = strconv.AppendInt(b, int64(h), 10)
  458. b = append(b, brx.timeSeparator...)
  459. if t.Minute() < 10 {
  460. b = append(b, '0')
  461. }
  462. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  463. b = append(b, brx.timeSeparator...)
  464. if t.Second() < 10 {
  465. b = append(b, '0')
  466. }
  467. b = strconv.AppendInt(b, int64(t.Second()), 10)
  468. b = append(b, []byte{0x20}...)
  469. if t.Hour() < 12 {
  470. b = append(b, brx.periodsAbbreviated[0]...)
  471. } else {
  472. b = append(b, brx.periodsAbbreviated[1]...)
  473. }
  474. b = append(b, []byte{0x20}...)
  475. tz, _ := t.Zone()
  476. b = append(b, tz...)
  477. return string(b)
  478. }
  479. // FmtTimeFull returns the full time representation of 't' for 'brx_IN'
  480. func (brx *brx_IN) FmtTimeFull(t time.Time) string {
  481. b := make([]byte, 0, 32)
  482. h := t.Hour()
  483. if h > 12 {
  484. h -= 12
  485. }
  486. b = strconv.AppendInt(b, int64(h), 10)
  487. b = append(b, brx.timeSeparator...)
  488. if t.Minute() < 10 {
  489. b = append(b, '0')
  490. }
  491. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  492. b = append(b, brx.timeSeparator...)
  493. if t.Second() < 10 {
  494. b = append(b, '0')
  495. }
  496. b = strconv.AppendInt(b, int64(t.Second()), 10)
  497. b = append(b, []byte{0x20}...)
  498. if t.Hour() < 12 {
  499. b = append(b, brx.periodsAbbreviated[0]...)
  500. } else {
  501. b = append(b, brx.periodsAbbreviated[1]...)
  502. }
  503. b = append(b, []byte{0x20}...)
  504. tz, _ := t.Zone()
  505. if btz, ok := brx.timezones[tz]; ok {
  506. b = append(b, btz...)
  507. } else {
  508. b = append(b, tz...)
  509. }
  510. return string(b)
  511. }