ur_IN.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. package ur_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 ur_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 'ur_IN' locale
  41. func New() locales.Translator {
  42. return &ur_IN{
  43. locale: "ur_IN",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: []locales.PluralRule{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 ", "BAM ", "BAN ", "BBD ", "BDT ", "BEC ", "BEF ", "BEL ", "BGL ", "BGM ", "BGN ", "BGO ", "BHD ", "BIF ", "BMD ", "BND ", "BOB ", "BOL ", "BOP ", "BOV ", "BRB ", "BRC ", "BRE ", "BRL ", "BRN ", "BRR ", "BRZ ", "BSD ", "BTN ", "BUK ", "BWP ", "BYB ", "BYR ", "BZD ", "CAD ", "CDF ", "CHE ", "CHF ", "CHW ", "CLE ", "CLF ", "CLP ", "CNX ", "CNY ", "COP ", "COU ", "CRC ", "CSD ", "CSK ", "CUC ", "CUP ", "CVE ", "CYP ", "CZK ", "DDM ", "DEM ", "DJF ", "DKK ", "DOP ", "DZD ", "ECS ", "ECV ", "EEK ", "EGP ", "ERN ", "ESA ", "ESB ", "ESP ", "ETB ", "EUR ", "FIM ", "FJD ", "FKP ", "FRF ", "GBP ", "GEK ", "GEL ", "GHC ", "GHS ", "GIP ", "GMD ", "GNF ", "GNS ", "GQE ", "GRD ", "GTQ ", "GWE ", "GWP ", "GYD ", "HKD ", "HNL ", "HRD ", "HRK ", "HTG ", "HUF ", "IDR ", "IEP ", "ILP ", "ILR ", "ILS ", "INR ", "IQD ", "IRR ", "ISJ ", "ISK ", "ITL ", "JMD ", "JOD ", "JPY ", "KES ", "KGS ", "KHR ", "KMF ", "KPW ", "KRH ", "KRO ", "KRW ", "KWD ", "KYD ", "KZT ", "LAK ", "LBP ", "LKR ", "LRD ", "LSL ", "LTL ", "LTT ", "LUC ", "LUF ", "LUL ", "LVL ", "LVR ", "LYD ", "MAD ", "MAF ", "MCF ", "MDC ", "MDL ", "MGA ", "MGF ", "MKD ", "MKN ", "MLF ", "MMK ", "MNT ", "MOP ", "MRO ", "MTL ", "MTP ", "MUR ", "MVP ", "MVR ", "MWK ", "MXN ", "MXP ", "MXV ", "MYR ", "MZE ", "MZM ", "MZN ", "NAD ", "NGN ", "NIC ", "NIO ", "NLG ", "NOK ", "NPR ", "NZD ", "OMR ", "PAB ", "PEI ", "PEN ", "PES ", "PGK ", "PHP ", "PKR", "PLN ", "PLZ ", "PTE ", "PYG ", "QAR ", "RHD ", "ROL ", "RON ", "RSD ", "RUB ", "RUR ", "RWF ", "SAR ", "SBD ", "SCR ", "SDD ", "SDG ", "SDP ", "SEK ", "SGD ", "SHP ", "SIT ", "SKK ", "SLL ", "SOS ", "SRD ", "SRG ", "SSP ", "STD ", "SUR ", "SVC ", "SYP ", "SZL ", "THB ", "TJR ", "TJS ", "TMM ", "TMT ", "TND ", "TOP ", "TPE ", "TRL ", "TRY ", "TTD ", "TWD ", "TZS ", "UAH ", "UAK ", "UGS ", "UGX ", "USD ", "USN ", "USS ", "UYI ", "UYP ", "UYU ", "UZS ", "VEB ", "VEF ", "VND ", "VNN ", "VUV ", "WST ", "XAF ", "XAG ", "XAU ", "XBA ", "XBB ", "XBC ", "XBD ", "XCD ", "XDR ", "XEU ", "XFO ", "XFU ", "XOF ", "XPD ", "XPF ", "XPT ", "XRE ", "XSU ", "XTS ", "XUA ", "XXX ", "YDD ", "YER ", "YUD ", "YUM ", "YUN ", "YUR ", "ZAL ", "ZAR ", "ZMK ", "ZMW ", "ZRN ", "ZRZ ", "ZWD ", "ZWL ", "ZWR "},
  55. currencyPositivePrefix: " ",
  56. currencyNegativePrefix: " ",
  57. monthsAbbreviated: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"},
  58. monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
  59. monthsWide: []string{"", "جنوری", "فروری", "مارچ", "اپریل", "مئی", "جون", "جولائی", "اگست", "ستمبر", "اکتوبر", "نومبر", "دسمبر"},
  60. daysAbbreviated: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"},
  61. daysNarrow: []string{"S", "M", "T", "W", "T", "F", "S"},
  62. daysShort: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"},
  63. daysWide: []string{"اتوار", "سوموار", "منگل", "بدھ", "جمعرات", "جمعہ", "ہفتہ"},
  64. periodsAbbreviated: []string{"AM", "PM"},
  65. periodsNarrow: []string{"a", "p"},
  66. periodsWide: []string{"قبل دوپہر", "بعد دوپہر"},
  67. erasAbbreviated: []string{"قبل مسیح", "عیسوی"},
  68. erasNarrow: []string{"", ""},
  69. erasWide: []string{"قبل مسیح", "عیسوی"},
  70. timezones: map[string]string{"MST": "MST", "BOT": "بولیویا ٹائم", "ECT": "ایکواڈور ٹائم", "BT": "بھوٹان ٹائم", "TMST": "ترکمانستان سمر ٹائم", "ACST": "آسٹریلین سنٹرل اسٹینڈرڈ ٹائم", "JST": "جاپان سٹینڈرڈ ٹائم", "AKDT": "الاسکا ڈے لائٹ ٹائم", "NZST": "نیوزی لینڈ سٹینڈرڈ ٹائم", "NZDT": "نیوزی لینڈ ڈے لائٹ ٹائم", "HAST": "ہوائی الیوٹیئن اسٹینڈرڈ ٹائم", "WART": "مغربی ارجنٹینا سٹینڈرڈ ٹائم", "WAT": "مغربی افریقہ سٹینڈرڈ ٹائم", "TMT": "ترکمانستان سٹینڈرڈ ٹائم", "MYT": "ملیشیا ٹائم", "SRT": "سورینام ٹائم", "CDT": "سنٹرل ڈے لائٹ ٹائم", "ARST": "ارجنٹینا سمر ٹائم", "CST": "سنٹرل اسٹینڈرڈ ٹائم", "CHADT": "چیتھم ڈے لائٹ ٹائم", "SAST": "جنوبی افریقہ سٹینڈرڈ ٹائم", "EDT": "ایسٹرن ڈے لائٹ ٹائم", "HKST": "ہانگ کانگ سمر ٹائم", "WARST": "مغربی ارجنٹینا سمر ٹائم", "GYT": "گیانا ٹائم", "AKST": "الاسکا اسٹینڈرڈ ٹائم", "WEZ": "مغربی یورپ کا معیاری وقت", "ACWDT": "آسٹریلین سنٹرل ویسٹرن ڈے لائٹ ٹائم", "AEST": "آسٹریلین ایسٹرن اسٹینڈرڈ ٹائم", "WAST": "مغربی افریقہ سمر ٹائم", "WIT": "مشرقی انڈونیشیا ٹائم", "MEZ": "وسطی یورپ کا معیاری وقت", "ADT": "اٹلانٹک ڈے لائٹ ٹائم", "HNT": "نیو فاؤنڈ لینڈ اسٹینڈرڈ ٹائم", "HAT": "نیو فاؤنڈ لینڈ ڈے لائٹ ٹائم", "OEZ": "مشرقی یورپ کا معیاری وقت", "LHST": "لارڈ ہووے اسٹینڈرڈ ٹائم", "AWDT": "آسٹریلین ویسٹرن ڈے لائٹ ٹائم", "CLST": "چلی سمر ٹائم", "EST": "ایسٹرن اسٹینڈرڈ ٹائم", "PDT": "پیسفک ڈے لائٹ ٹائم", "AWST": "آسٹریلیا ویسٹرن اسٹینڈرڈ ٹائم", "COST": "کولمبیا سمر ٹائم", "GFT": "فرینچ گیانا ٹائم", "MESZ": "وسطی یورپ کا موسم گرما کا وقت", "IST": "انڈیا سٹینڈرڈ ٹائم", "OESZ": "مشرقی یورپ کا موسم گرما کا وقت", "ACDT": "آسٹریلین سنٹرل ڈے لائٹ ٹائم", "UYT": "یوروگوئے سٹینڈرڈ ٹائم", "CLT": "چلی سٹینڈرڈ ٹائم", "CAT": "وسطی افریقہ ٹائم", "AST": "اٹلانٹک اسٹینڈرڈ ٹائم", "MDT": "MDT", "SGT": "سنگاپور سٹینڈرڈ ٹائم", "GMT": "گرین وچ مین ٹائم", "ART": "ارجنٹینا سٹینڈرڈ ٹائم", "∅∅∅": "ایمیزون سمر ٹائم", "ChST": "چامورو سٹینڈرڈ ٹائم", "WESZ": "مغربی یورپ کا موسم گرما کا وقت", "HADT": "ہوائی الیوٹیئن ڈے لائٹ ٹائم", "COT": "کولمبیا سٹینڈرڈ ٹائم", "WITA": "وسطی انڈونیشیا ٹائم", "WIB": "مغربی انڈونیشیا ٹائم", "LHDT": "لارڈ ہووے ڈے لائٹ ٹائم", "UYST": "یوروگوئے سمر ٹائم", "AEDT": "آسٹریلین ایسٹرن ڈے لائٹ ٹائم", "ACWST": "آسٹریلین سنٹرل ویسٹرن اسٹینڈرڈ ٹائم", "HKT": "ہانگ کانگ سٹینڈرڈ ٹائم", "EAT": "مشرقی افریقہ ٹائم", "JDT": "جاپان ڈے لائٹ ٹائم", "PST": "پیسفک اسٹینڈرڈ ٹائم", "CHAST": "چیتھم اسٹینڈرڈ ٹائم", "VET": "وینزوئیلا ٹائم"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (ur *ur_IN) Locale() string {
  75. return ur.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'ur_IN'
  78. func (ur *ur_IN) PluralsCardinal() []locales.PluralRule {
  79. return ur.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ur_IN'
  82. func (ur *ur_IN) PluralsOrdinal() []locales.PluralRule {
  83. return ur.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'ur_IN'
  86. func (ur *ur_IN) PluralsRange() []locales.PluralRule {
  87. return ur.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ur_IN'
  90. func (ur *ur_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. i := int64(n)
  93. if i == 1 && v == 0 {
  94. return locales.PluralRuleOne
  95. }
  96. return locales.PluralRuleOther
  97. }
  98. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ur_IN'
  99. func (ur *ur_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  100. return locales.PluralRuleOther
  101. }
  102. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ur_IN'
  103. func (ur *ur_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  104. return locales.PluralRuleOther
  105. }
  106. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  107. func (ur *ur_IN) MonthAbbreviated(month time.Month) string {
  108. return ur.monthsAbbreviated[month]
  109. }
  110. // MonthsAbbreviated returns the locales abbreviated months
  111. func (ur *ur_IN) MonthsAbbreviated() []string {
  112. return ur.monthsAbbreviated[1:]
  113. }
  114. // MonthNarrow returns the locales narrow month given the 'month' provided
  115. func (ur *ur_IN) MonthNarrow(month time.Month) string {
  116. return ur.monthsNarrow[month]
  117. }
  118. // MonthsNarrow returns the locales narrow months
  119. func (ur *ur_IN) MonthsNarrow() []string {
  120. return ur.monthsNarrow[1:]
  121. }
  122. // MonthWide returns the locales wide month given the 'month' provided
  123. func (ur *ur_IN) MonthWide(month time.Month) string {
  124. return ur.monthsWide[month]
  125. }
  126. // MonthsWide returns the locales wide months
  127. func (ur *ur_IN) MonthsWide() []string {
  128. return ur.monthsWide[1:]
  129. }
  130. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  131. func (ur *ur_IN) WeekdayAbbreviated(weekday time.Weekday) string {
  132. return ur.daysAbbreviated[weekday]
  133. }
  134. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  135. func (ur *ur_IN) WeekdaysAbbreviated() []string {
  136. return ur.daysAbbreviated
  137. }
  138. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  139. func (ur *ur_IN) WeekdayNarrow(weekday time.Weekday) string {
  140. return ur.daysNarrow[weekday]
  141. }
  142. // WeekdaysNarrow returns the locales narrow weekdays
  143. func (ur *ur_IN) WeekdaysNarrow() []string {
  144. return ur.daysNarrow
  145. }
  146. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  147. func (ur *ur_IN) WeekdayShort(weekday time.Weekday) string {
  148. return ur.daysShort[weekday]
  149. }
  150. // WeekdaysShort returns the locales short weekdays
  151. func (ur *ur_IN) WeekdaysShort() []string {
  152. return ur.daysShort
  153. }
  154. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  155. func (ur *ur_IN) WeekdayWide(weekday time.Weekday) string {
  156. return ur.daysWide[weekday]
  157. }
  158. // WeekdaysWide returns the locales wide weekdays
  159. func (ur *ur_IN) WeekdaysWide() []string {
  160. return ur.daysWide
  161. }
  162. // FmtNumber returns 'num' with digits/precision of 'v' for 'ur_IN' and handles both Whole and Real numbers based on 'v'
  163. func (ur *ur_IN) FmtNumber(num float64, v uint64) string {
  164. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  165. l := len(s) + 8 + 1*len(s[:len(s)-int(v)-1])/3
  166. count := 0
  167. inWhole := v == 0
  168. b := make([]byte, 0, l)
  169. for i := len(s) - 1; i >= 0; i-- {
  170. if s[i] == '.' {
  171. b = append(b, ur.decimal[0])
  172. inWhole = true
  173. continue
  174. }
  175. if inWhole {
  176. if count == 3 {
  177. b = append(b, ur.group[0])
  178. count = 1
  179. } else {
  180. count++
  181. }
  182. }
  183. b = append(b, s[i])
  184. }
  185. if num < 0 {
  186. for j := len(ur.minus) - 1; j >= 0; j-- {
  187. b = append(b, ur.minus[j])
  188. }
  189. }
  190. // reverse
  191. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  192. b[i], b[j] = b[j], b[i]
  193. }
  194. return string(b)
  195. }
  196. // FmtPercent returns 'num' with digits/precision of 'v' for 'ur_IN' and handles both Whole and Real numbers based on 'v'
  197. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  198. func (ur *ur_IN) FmtPercent(num float64, v uint64) string {
  199. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  200. l := len(s) + 9
  201. b := make([]byte, 0, l)
  202. for i := len(s) - 1; i >= 0; i-- {
  203. if s[i] == '.' {
  204. b = append(b, ur.decimal[0])
  205. continue
  206. }
  207. b = append(b, s[i])
  208. }
  209. if num < 0 {
  210. for j := len(ur.minus) - 1; j >= 0; j-- {
  211. b = append(b, ur.minus[j])
  212. }
  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. b = append(b, ur.percent...)
  219. return string(b)
  220. }
  221. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ur_IN'
  222. func (ur *ur_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  223. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  224. symbol := ur.currencies[currency]
  225. l := len(s) + len(symbol) + 10 + 1*len(s[:len(s)-int(v)-1])/3
  226. count := 0
  227. inWhole := v == 0
  228. inSecondary := false
  229. groupThreshold := 3
  230. b := make([]byte, 0, l)
  231. for i := len(s) - 1; i >= 0; i-- {
  232. if s[i] == '.' {
  233. b = append(b, ur.decimal[0])
  234. inWhole = true
  235. continue
  236. }
  237. if inWhole {
  238. if count == groupThreshold {
  239. b = append(b, ur.group[0])
  240. count = 1
  241. if !inSecondary {
  242. inSecondary = true
  243. groupThreshold = 2
  244. }
  245. } else {
  246. count++
  247. }
  248. }
  249. b = append(b, s[i])
  250. }
  251. for j := len(symbol) - 1; j >= 0; j-- {
  252. b = append(b, symbol[j])
  253. }
  254. for j := len(ur.currencyPositivePrefix) - 1; j >= 0; j-- {
  255. b = append(b, ur.currencyPositivePrefix[j])
  256. }
  257. if num < 0 {
  258. for j := len(ur.minus) - 1; j >= 0; j-- {
  259. b = append(b, ur.minus[j])
  260. }
  261. }
  262. // reverse
  263. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  264. b[i], b[j] = b[j], b[i]
  265. }
  266. if int(v) < 2 {
  267. if v == 0 {
  268. b = append(b, ur.decimal...)
  269. }
  270. for i := 0; i < 2-int(v); i++ {
  271. b = append(b, '0')
  272. }
  273. }
  274. return string(b)
  275. }
  276. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ur_IN'
  277. // in accounting notation.
  278. func (ur *ur_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  279. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  280. symbol := ur.currencies[currency]
  281. l := len(s) + len(symbol) + 10 + 1*len(s[:len(s)-int(v)-1])/3
  282. count := 0
  283. inWhole := v == 0
  284. inSecondary := false
  285. groupThreshold := 3
  286. b := make([]byte, 0, l)
  287. for i := len(s) - 1; i >= 0; i-- {
  288. if s[i] == '.' {
  289. b = append(b, ur.decimal[0])
  290. inWhole = true
  291. continue
  292. }
  293. if inWhole {
  294. if count == groupThreshold {
  295. b = append(b, ur.group[0])
  296. count = 1
  297. if !inSecondary {
  298. inSecondary = true
  299. groupThreshold = 2
  300. }
  301. } else {
  302. count++
  303. }
  304. }
  305. b = append(b, s[i])
  306. }
  307. if num < 0 {
  308. for j := len(symbol) - 1; j >= 0; j-- {
  309. b = append(b, symbol[j])
  310. }
  311. for j := len(ur.currencyNegativePrefix) - 1; j >= 0; j-- {
  312. b = append(b, ur.currencyNegativePrefix[j])
  313. }
  314. for j := len(ur.minus) - 1; j >= 0; j-- {
  315. b = append(b, ur.minus[j])
  316. }
  317. } else {
  318. for j := len(symbol) - 1; j >= 0; j-- {
  319. b = append(b, symbol[j])
  320. }
  321. for j := len(ur.currencyPositivePrefix) - 1; j >= 0; j-- {
  322. b = append(b, ur.currencyPositivePrefix[j])
  323. }
  324. }
  325. // reverse
  326. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  327. b[i], b[j] = b[j], b[i]
  328. }
  329. if int(v) < 2 {
  330. if v == 0 {
  331. b = append(b, ur.decimal...)
  332. }
  333. for i := 0; i < 2-int(v); i++ {
  334. b = append(b, '0')
  335. }
  336. }
  337. return string(b)
  338. }
  339. // FmtDateShort returns the short date representation of 't' for 'ur_IN'
  340. func (ur *ur_IN) FmtDateShort(t time.Time) string {
  341. b := make([]byte, 0, 32)
  342. b = strconv.AppendInt(b, int64(t.Day()), 10)
  343. b = append(b, []byte{0x2f}...)
  344. b = strconv.AppendInt(b, int64(t.Month()), 10)
  345. b = append(b, []byte{0x2f}...)
  346. if t.Year() > 9 {
  347. b = append(b, strconv.Itoa(t.Year())[2:]...)
  348. } else {
  349. b = append(b, strconv.Itoa(t.Year())[1:]...)
  350. }
  351. return string(b)
  352. }
  353. // FmtDateMedium returns the medium date representation of 't' for 'ur_IN'
  354. func (ur *ur_IN) FmtDateMedium(t time.Time) string {
  355. b := make([]byte, 0, 32)
  356. b = strconv.AppendInt(b, int64(t.Day()), 10)
  357. b = append(b, []byte{0x20}...)
  358. b = append(b, ur.monthsAbbreviated[t.Month()]...)
  359. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  360. b = strconv.AppendInt(b, int64(t.Year()), 10)
  361. return string(b)
  362. }
  363. // FmtDateLong returns the long date representation of 't' for 'ur_IN'
  364. func (ur *ur_IN) 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{0x20}...)
  368. b = append(b, ur.monthsWide[t.Month()]...)
  369. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  370. b = strconv.AppendInt(b, int64(t.Year()), 10)
  371. return string(b)
  372. }
  373. // FmtDateFull returns the full date representation of 't' for 'ur_IN'
  374. func (ur *ur_IN) FmtDateFull(t time.Time) string {
  375. b := make([]byte, 0, 32)
  376. b = append(b, ur.daysWide[t.Weekday()]...)
  377. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  378. b = strconv.AppendInt(b, int64(t.Day()), 10)
  379. b = append(b, []byte{0x20}...)
  380. b = append(b, ur.monthsWide[t.Month()]...)
  381. b = append(b, []byte{0xd8, 0x8c, 0x20}...)
  382. b = strconv.AppendInt(b, int64(t.Year()), 10)
  383. return string(b)
  384. }
  385. // FmtTimeShort returns the short time representation of 't' for 'ur_IN'
  386. func (ur *ur_IN) FmtTimeShort(t time.Time) string {
  387. b := make([]byte, 0, 32)
  388. h := t.Hour()
  389. if h > 12 {
  390. h -= 12
  391. }
  392. b = strconv.AppendInt(b, int64(h), 10)
  393. b = append(b, ur.timeSeparator...)
  394. if t.Minute() < 10 {
  395. b = append(b, '0')
  396. }
  397. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  398. b = append(b, []byte{0x20}...)
  399. if t.Hour() < 12 {
  400. b = append(b, ur.periodsAbbreviated[0]...)
  401. } else {
  402. b = append(b, ur.periodsAbbreviated[1]...)
  403. }
  404. return string(b)
  405. }
  406. // FmtTimeMedium returns the medium time representation of 't' for 'ur_IN'
  407. func (ur *ur_IN) FmtTimeMedium(t time.Time) string {
  408. b := make([]byte, 0, 32)
  409. h := t.Hour()
  410. if h > 12 {
  411. h -= 12
  412. }
  413. b = strconv.AppendInt(b, int64(h), 10)
  414. b = append(b, ur.timeSeparator...)
  415. if t.Minute() < 10 {
  416. b = append(b, '0')
  417. }
  418. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  419. b = append(b, ur.timeSeparator...)
  420. if t.Second() < 10 {
  421. b = append(b, '0')
  422. }
  423. b = strconv.AppendInt(b, int64(t.Second()), 10)
  424. b = append(b, []byte{0x20}...)
  425. if t.Hour() < 12 {
  426. b = append(b, ur.periodsAbbreviated[0]...)
  427. } else {
  428. b = append(b, ur.periodsAbbreviated[1]...)
  429. }
  430. return string(b)
  431. }
  432. // FmtTimeLong returns the long time representation of 't' for 'ur_IN'
  433. func (ur *ur_IN) FmtTimeLong(t time.Time) string {
  434. b := make([]byte, 0, 32)
  435. h := t.Hour()
  436. if h > 12 {
  437. h -= 12
  438. }
  439. b = strconv.AppendInt(b, int64(h), 10)
  440. b = append(b, ur.timeSeparator...)
  441. if t.Minute() < 10 {
  442. b = append(b, '0')
  443. }
  444. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  445. b = append(b, ur.timeSeparator...)
  446. if t.Second() < 10 {
  447. b = append(b, '0')
  448. }
  449. b = strconv.AppendInt(b, int64(t.Second()), 10)
  450. b = append(b, []byte{0x20}...)
  451. if t.Hour() < 12 {
  452. b = append(b, ur.periodsAbbreviated[0]...)
  453. } else {
  454. b = append(b, ur.periodsAbbreviated[1]...)
  455. }
  456. b = append(b, []byte{0x20}...)
  457. tz, _ := t.Zone()
  458. b = append(b, tz...)
  459. return string(b)
  460. }
  461. // FmtTimeFull returns the full time representation of 't' for 'ur_IN'
  462. func (ur *ur_IN) FmtTimeFull(t time.Time) string {
  463. b := make([]byte, 0, 32)
  464. h := t.Hour()
  465. if h > 12 {
  466. h -= 12
  467. }
  468. b = strconv.AppendInt(b, int64(h), 10)
  469. b = append(b, ur.timeSeparator...)
  470. if t.Minute() < 10 {
  471. b = append(b, '0')
  472. }
  473. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  474. b = append(b, ur.timeSeparator...)
  475. if t.Second() < 10 {
  476. b = append(b, '0')
  477. }
  478. b = strconv.AppendInt(b, int64(t.Second()), 10)
  479. b = append(b, []byte{0x20}...)
  480. if t.Hour() < 12 {
  481. b = append(b, ur.periodsAbbreviated[0]...)
  482. } else {
  483. b = append(b, ur.periodsAbbreviated[1]...)
  484. }
  485. b = append(b, []byte{0x20}...)
  486. tz, _ := t.Zone()
  487. if btz, ok := ur.timezones[tz]; ok {
  488. b = append(b, btz...)
  489. } else {
  490. b = append(b, tz...)
  491. }
  492. return string(b)
  493. }