gu_IN.go 24 KB

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