uz.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. package uz
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type uz 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 'uz' locale
  41. func New() locales.Translator {
  42. return &uz{
  43. locale: "uz",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: []locales.PluralRule{6, 2},
  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 ", "A$", "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 ", "R$", "BRN ", "BRR ", "BRZ ", "BSD", "BTN", "BUK ", "BWP", "BYB ", "BYR", "BZD", "CA$", "CDF", "CHE ", "CHF", "CHW ", "CLE ", "CLF ", "CLP", "CNX ", "CN¥", "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", "€", "FIM ", "FJD", "FKP", "FRF ", "£", "GEK ", "GEL", "GHC ", "GHS", "GIP", "GMD", "GNF", "GNS ", "GQE ", "GRD ", "GTQ", "GWE ", "GWP ", "GYD", "HK$", "HNL", "HRD ", "HRK", "HTG", "HUF", "IDR", "IEP ", "ILP ", "ILR ", "₪", "₹", "IQD", "IRR", "ISJ ", "ISK", "ITL ", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH ", "KRO ", "₩", "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", "MX$", "MXP ", "MXV ", "MYR", "MZE ", "MZM ", "MZN", "NAD", "NGN", "NIC ", "NIO", "NLG ", "NOK", "NPR", "NZ$", "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", "NT$", "TZS", "UAH", "UAK ", "UGS ", "UGX", "US$", "USN ", "USS ", "UYI ", "UYP ", "UYU", "soʻm", "VEB ", "VEF", "₫", "VNN ", "VUV", "WST", "FCFA", "XAG ", "XAU ", "XBA ", "XBB ", "XBC ", "XBD ", "EC$", "XDR ", "XEU ", "XFO ", "XFU ", "CFA", "XPD ", "CFPF", "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{"", "yan", "fev", "mar", "apr", "may", "iyn", "iyl", "avg", "sen", "okt", "noy", "dek"},
  58. monthsNarrow: []string{"", "Y", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"},
  59. monthsWide: []string{"", "yanvar", "fevral", "mart", "aprel", "may", "iyun", "iyul", "avgust", "Sentabr", "Oktabr", "noyabr", "dekabr"},
  60. daysAbbreviated: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"},
  61. daysNarrow: []string{"Y", "D", "S", "C", "P", "J", "S"},
  62. daysShort: []string{"Ya", "Du", "Se", "Ch", "Pa", "Ju", "Sh"},
  63. daysWide: []string{"yakshanba", "dushanba", "seshanba", "chorshanba", "payshanba", "juma", "shanba"},
  64. periodsAbbreviated: []string{"TO", "TK"},
  65. periodsNarrow: []string{"TO", "TK"},
  66. periodsWide: []string{"TO", "TK"},
  67. erasAbbreviated: []string{"", ""},
  68. erasNarrow: []string{"", ""},
  69. erasWide: []string{"", ""},
  70. timezones: map[string]string{"ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "ARST": "Argentina yozgi vaqti", "IST": "Hindiston vaqti", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "ChST": "Chamorro standart vaqti", "COST": "Kolumbiya yozgi vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "SRT": "Surinam vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "JST": "Yaponiya standart vaqti", "AKDT": "Alyaska yozgi vaqti", "UYT": "Urugvay standart vaqti", "CLST": "Chili yozgi vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "COT": "Kolumbiya standart vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "BOT": "Boliviya vaqti", "AST": "Atlantika standart vaqti", "HKT": "Gonkong standart vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "ART": "Argentina standart vaqti", "CAT": "Markaziy Afrika vaqti", "SGT": "Singapur vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "JDT": "Yaponiya yozgi vaqti", "SAST": "Janubiy Afrika standart vaqti", "MDT": "MDT", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "NZST": "Yangi Zelandiya standart vaqti", "EST": "Sharqiy Amerika standart vaqti", "HKST": "Gonkong yozgi vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "PST": "Shimoliy Amerika Tinch okeani standart vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "ECT": "Ekvador vaqti", "HAST": "Gavayi-aleut standart vaqti", "UYST": "Urugvay yozgi vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "CLT": "Chili standart vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "EAT": "Sharqiy Afrika vaqti", "MST": "MST", "BT": "Butan vaqti", "HNT": "Nyufaundlend standart vaqti", "∅∅∅": "Amazonka yozgi vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "CHAST": "Chatem standart vaqti", "TMST": "Turkmaniston yozgi vaqti", "LHST": "Lord-Xau standart vaqti", "GYT": "Gayana vaqti", "AKST": "Alyaska standart vaqti", "PDT": "Shimoliy Amerika Tinch okeani yozgi vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "GFT": "Fransuz Gvianasi vaqti", "WIT": "Sharqiy Indoneziya vaqti", "CST": "Markaziy Amerika standart vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "TMT": "Turkmaniston standart vaqti", "LHDT": "Lord-Xau yozgi vaqti", "MYT": "Malayziya vaqti", "VET": "Venesuela vaqti", "GMT": "Grinvich o‘rtacha vaqti", "WITA": "Markaziy Indoneziya vaqti", "ADT": "Atlantika yozgi vaqti", "WAT": "Gʻarbiy Afrika standart vaqti", "CHADT": "Chatem yozgi vaqti", "EDT": "Sharqiy Amerika yozgi vaqti"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (uz *uz) Locale() string {
  75. return uz.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'uz'
  78. func (uz *uz) PluralsCardinal() []locales.PluralRule {
  79. return uz.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'uz'
  82. func (uz *uz) PluralsOrdinal() []locales.PluralRule {
  83. return uz.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'uz'
  86. func (uz *uz) PluralsRange() []locales.PluralRule {
  87. return uz.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'uz'
  90. func (uz *uz) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. if n == 1 {
  93. return locales.PluralRuleOne
  94. }
  95. return locales.PluralRuleOther
  96. }
  97. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'uz'
  98. func (uz *uz) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  99. return locales.PluralRuleOther
  100. }
  101. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'uz'
  102. func (uz *uz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  103. start := uz.CardinalPluralRule(num1, v1)
  104. end := uz.CardinalPluralRule(num2, v2)
  105. if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  106. return locales.PluralRuleOther
  107. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  108. return locales.PluralRuleOne
  109. }
  110. return locales.PluralRuleOther
  111. }
  112. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  113. func (uz *uz) MonthAbbreviated(month time.Month) string {
  114. return uz.monthsAbbreviated[month]
  115. }
  116. // MonthsAbbreviated returns the locales abbreviated months
  117. func (uz *uz) MonthsAbbreviated() []string {
  118. return uz.monthsAbbreviated[1:]
  119. }
  120. // MonthNarrow returns the locales narrow month given the 'month' provided
  121. func (uz *uz) MonthNarrow(month time.Month) string {
  122. return uz.monthsNarrow[month]
  123. }
  124. // MonthsNarrow returns the locales narrow months
  125. func (uz *uz) MonthsNarrow() []string {
  126. return uz.monthsNarrow[1:]
  127. }
  128. // MonthWide returns the locales wide month given the 'month' provided
  129. func (uz *uz) MonthWide(month time.Month) string {
  130. return uz.monthsWide[month]
  131. }
  132. // MonthsWide returns the locales wide months
  133. func (uz *uz) MonthsWide() []string {
  134. return uz.monthsWide[1:]
  135. }
  136. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  137. func (uz *uz) WeekdayAbbreviated(weekday time.Weekday) string {
  138. return uz.daysAbbreviated[weekday]
  139. }
  140. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  141. func (uz *uz) WeekdaysAbbreviated() []string {
  142. return uz.daysAbbreviated
  143. }
  144. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  145. func (uz *uz) WeekdayNarrow(weekday time.Weekday) string {
  146. return uz.daysNarrow[weekday]
  147. }
  148. // WeekdaysNarrow returns the locales narrow weekdays
  149. func (uz *uz) WeekdaysNarrow() []string {
  150. return uz.daysNarrow
  151. }
  152. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  153. func (uz *uz) WeekdayShort(weekday time.Weekday) string {
  154. return uz.daysShort[weekday]
  155. }
  156. // WeekdaysShort returns the locales short weekdays
  157. func (uz *uz) WeekdaysShort() []string {
  158. return uz.daysShort
  159. }
  160. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  161. func (uz *uz) WeekdayWide(weekday time.Weekday) string {
  162. return uz.daysWide[weekday]
  163. }
  164. // WeekdaysWide returns the locales wide weekdays
  165. func (uz *uz) WeekdaysWide() []string {
  166. return uz.daysWide
  167. }
  168. // FmtNumber returns 'num' with digits/precision of 'v' for 'uz' and handles both Whole and Real numbers based on 'v'
  169. func (uz *uz) FmtNumber(num float64, v uint64) string {
  170. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  171. l := len(s) + 3 + 2*len(s[:len(s)-int(v)-1])/3
  172. count := 0
  173. inWhole := v == 0
  174. b := make([]byte, 0, l)
  175. for i := len(s) - 1; i >= 0; i-- {
  176. if s[i] == '.' {
  177. for j := len(uz.decimal) - 1; j >= 0; j-- {
  178. b = append(b, uz.decimal[j])
  179. }
  180. inWhole = true
  181. continue
  182. }
  183. if inWhole {
  184. if count == 3 {
  185. for j := len(uz.group) - 1; j >= 0; j-- {
  186. b = append(b, uz.group[j])
  187. }
  188. count = 1
  189. } else {
  190. count++
  191. }
  192. }
  193. b = append(b, s[i])
  194. }
  195. if num < 0 {
  196. b = append(b, uz.minus[0])
  197. }
  198. // reverse
  199. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  200. b[i], b[j] = b[j], b[i]
  201. }
  202. return string(b)
  203. }
  204. // FmtPercent returns 'num' with digits/precision of 'v' for 'uz' and handles both Whole and Real numbers based on 'v'
  205. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  206. func (uz *uz) FmtPercent(num float64, v uint64) string {
  207. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  208. l := len(s) + 5
  209. b := make([]byte, 0, l)
  210. for i := len(s) - 1; i >= 0; i-- {
  211. if s[i] == '.' {
  212. for j := len(uz.decimal) - 1; j >= 0; j-- {
  213. b = append(b, uz.decimal[j])
  214. }
  215. continue
  216. }
  217. b = append(b, s[i])
  218. }
  219. if num < 0 {
  220. b = append(b, uz.minus[0])
  221. }
  222. // reverse
  223. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  224. b[i], b[j] = b[j], b[i]
  225. }
  226. b = append(b, uz.percent...)
  227. return string(b)
  228. }
  229. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz'
  230. func (uz *uz) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  231. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  232. symbol := uz.currencies[currency]
  233. l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3
  234. count := 0
  235. inWhole := v == 0
  236. b := make([]byte, 0, l)
  237. for i := len(s) - 1; i >= 0; i-- {
  238. if s[i] == '.' {
  239. for j := len(uz.decimal) - 1; j >= 0; j-- {
  240. b = append(b, uz.decimal[j])
  241. }
  242. inWhole = true
  243. continue
  244. }
  245. if inWhole {
  246. if count == 3 {
  247. for j := len(uz.group) - 1; j >= 0; j-- {
  248. b = append(b, uz.group[j])
  249. }
  250. count = 1
  251. } else {
  252. count++
  253. }
  254. }
  255. b = append(b, s[i])
  256. }
  257. for j := len(symbol) - 1; j >= 0; j-- {
  258. b = append(b, symbol[j])
  259. }
  260. for j := len(uz.currencyPositivePrefix) - 1; j >= 0; j-- {
  261. b = append(b, uz.currencyPositivePrefix[j])
  262. }
  263. if num < 0 {
  264. b = append(b, uz.minus[0])
  265. }
  266. // reverse
  267. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  268. b[i], b[j] = b[j], b[i]
  269. }
  270. if int(v) < 2 {
  271. if v == 0 {
  272. b = append(b, uz.decimal...)
  273. }
  274. for i := 0; i < 2-int(v); i++ {
  275. b = append(b, '0')
  276. }
  277. }
  278. return string(b)
  279. }
  280. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz'
  281. // in accounting notation.
  282. func (uz *uz) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  283. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  284. symbol := uz.currencies[currency]
  285. l := len(s) + len(symbol) + 5 + 2*len(s[:len(s)-int(v)-1])/3
  286. count := 0
  287. inWhole := v == 0
  288. b := make([]byte, 0, l)
  289. for i := len(s) - 1; i >= 0; i-- {
  290. if s[i] == '.' {
  291. for j := len(uz.decimal) - 1; j >= 0; j-- {
  292. b = append(b, uz.decimal[j])
  293. }
  294. inWhole = true
  295. continue
  296. }
  297. if inWhole {
  298. if count == 3 {
  299. for j := len(uz.group) - 1; j >= 0; j-- {
  300. b = append(b, uz.group[j])
  301. }
  302. count = 1
  303. } else {
  304. count++
  305. }
  306. }
  307. b = append(b, s[i])
  308. }
  309. if num < 0 {
  310. for j := len(symbol) - 1; j >= 0; j-- {
  311. b = append(b, symbol[j])
  312. }
  313. for j := len(uz.currencyNegativePrefix) - 1; j >= 0; j-- {
  314. b = append(b, uz.currencyNegativePrefix[j])
  315. }
  316. b = append(b, uz.minus[0])
  317. } else {
  318. for j := len(symbol) - 1; j >= 0; j-- {
  319. b = append(b, symbol[j])
  320. }
  321. for j := len(uz.currencyPositivePrefix) - 1; j >= 0; j-- {
  322. b = append(b, uz.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, uz.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 'uz'
  340. func (uz *uz) FmtDateShort(t time.Time) string {
  341. b := make([]byte, 0, 32)
  342. if t.Day() < 10 {
  343. b = append(b, '0')
  344. }
  345. b = strconv.AppendInt(b, int64(t.Day()), 10)
  346. b = append(b, []byte{0x2f}...)
  347. if t.Month() < 10 {
  348. b = append(b, '0')
  349. }
  350. b = strconv.AppendInt(b, int64(t.Month()), 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 'uz'
  360. func (uz *uz) FmtDateMedium(t time.Time) string {
  361. b := make([]byte, 0, 32)
  362. b = strconv.AppendInt(b, int64(t.Day()), 10)
  363. b = append(b, []byte{0x2d}...)
  364. b = append(b, uz.monthsAbbreviated[t.Month()]...)
  365. b = append(b, []byte{0x2c, 0x20}...)
  366. b = strconv.AppendInt(b, int64(t.Year()), 10)
  367. return string(b)
  368. }
  369. // FmtDateLong returns the long date representation of 't' for 'uz'
  370. func (uz *uz) 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{0x2d}...)
  374. b = append(b, uz.monthsWide[t.Month()]...)
  375. b = append(b, []byte{0x2c, 0x20}...)
  376. b = strconv.AppendInt(b, int64(t.Year()), 10)
  377. return string(b)
  378. }
  379. // FmtDateFull returns the full date representation of 't' for 'uz'
  380. func (uz *uz) FmtDateFull(t time.Time) string {
  381. b := make([]byte, 0, 32)
  382. b = append(b, uz.daysWide[t.Weekday()]...)
  383. b = append(b, []byte{0x2c, 0x20}...)
  384. b = strconv.AppendInt(b, int64(t.Year()), 10)
  385. b = append(b, []byte{0x20}...)
  386. b = append(b, uz.monthsWide[t.Month()]...)
  387. b = append(b, []byte{0x20}...)
  388. if t.Day() < 10 {
  389. b = append(b, '0')
  390. }
  391. b = strconv.AppendInt(b, int64(t.Day()), 10)
  392. return string(b)
  393. }
  394. // FmtTimeShort returns the short time representation of 't' for 'uz'
  395. func (uz *uz) FmtTimeShort(t time.Time) string {
  396. b := make([]byte, 0, 32)
  397. if t.Hour() < 10 {
  398. b = append(b, '0')
  399. }
  400. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  401. b = append(b, uz.timeSeparator...)
  402. if t.Minute() < 10 {
  403. b = append(b, '0')
  404. }
  405. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  406. return string(b)
  407. }
  408. // FmtTimeMedium returns the medium time representation of 't' for 'uz'
  409. func (uz *uz) FmtTimeMedium(t time.Time) string {
  410. b := make([]byte, 0, 32)
  411. if t.Hour() < 10 {
  412. b = append(b, '0')
  413. }
  414. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  415. b = append(b, uz.timeSeparator...)
  416. if t.Minute() < 10 {
  417. b = append(b, '0')
  418. }
  419. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  420. b = append(b, uz.timeSeparator...)
  421. if t.Second() < 10 {
  422. b = append(b, '0')
  423. }
  424. b = strconv.AppendInt(b, int64(t.Second()), 10)
  425. return string(b)
  426. }
  427. // FmtTimeLong returns the long time representation of 't' for 'uz'
  428. func (uz *uz) FmtTimeLong(t time.Time) string {
  429. b := make([]byte, 0, 32)
  430. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  431. b = append(b, uz.timeSeparator...)
  432. if t.Minute() < 10 {
  433. b = append(b, '0')
  434. }
  435. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  436. b = append(b, uz.timeSeparator...)
  437. if t.Second() < 10 {
  438. b = append(b, '0')
  439. }
  440. b = strconv.AppendInt(b, int64(t.Second()), 10)
  441. b = append(b, []byte{0x20, 0x28}...)
  442. tz, _ := t.Zone()
  443. b = append(b, tz...)
  444. b = append(b, []byte{0x29}...)
  445. return string(b)
  446. }
  447. // FmtTimeFull returns the full time representation of 't' for 'uz'
  448. func (uz *uz) FmtTimeFull(t time.Time) string {
  449. b := make([]byte, 0, 32)
  450. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  451. b = append(b, uz.timeSeparator...)
  452. if t.Minute() < 10 {
  453. b = append(b, '0')
  454. }
  455. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  456. b = append(b, uz.timeSeparator...)
  457. if t.Second() < 10 {
  458. b = append(b, '0')
  459. }
  460. b = strconv.AppendInt(b, int64(t.Second()), 10)
  461. b = append(b, []byte{0x20, 0x28}...)
  462. tz, _ := t.Zone()
  463. if btz, ok := uz.timezones[tz]; ok {
  464. b = append(b, btz...)
  465. } else {
  466. b = append(b, tz...)
  467. }
  468. b = append(b, []byte{0x29}...)
  469. return string(b)
  470. }