uz.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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. currencyPositiveSuffix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the '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{2, 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", "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", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "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", "STN", "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. currencyPositiveSuffix: " ",
  56. currencyNegativeSuffix: " ",
  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{"Yak", "Dush", "Sesh", "Chor", "Pay", "Jum", "Shan"},
  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{"m.a.", "milodiy"},
  68. erasNarrow: []string{"", ""},
  69. erasWide: []string{"miloddan avvalgi", "milodiy"},
  70. timezones: map[string]string{"ECT": "Ekvador vaqti", "HNOG": "G‘arbiy Grenlandiya standart vaqti", "ACDT": "Markaziy Avstraliya yozgi vaqti", "AEST": "Sharqiy Avstraliya standart vaqti", "HNEG": "Sharqiy Grenlandiya standart vaqti", "UYT": "Urugvay standart vaqti", "ChST": "Chamorro standart vaqti", "ADT": "Atlantika yozgi vaqti", "WESZ": "G‘arbiy Yevropa yozgi vaqti", "HEEG": "Sharqiy Grenlandiya yozgi vaqti", "ARST": "Argentina yozgi vaqti", "OESZ": "Sharqiy Yevropa yozgi vaqti", "HAST": "Gavayi-aleut standart vaqti", "HNPMX": "Meksika Tinch okeani standart vaqti", "MDT": "MDT", "CLST": "Chili yozgi vaqti", "OEZ": "Sharqiy Yevropa standart vaqti", "CHADT": "Chatem yozgi vaqti", "HEPMX": "Meksika Tinch okeani yozgi vaqti", "UYST": "Urugvay yozgi vaqti", "HKST": "Gonkong yozgi vaqti", "IST": "Hindiston standart vaqti", "LHST": "Lord-Xau standart vaqti", "CAT": "Markaziy Afrika vaqti", "ART": "Argentina standart vaqti", "COT": "Kolumbiya standart vaqti", "HADT": "Gavayi-aleut yozgi vaqti", "WEZ": "G‘arbiy Yevropa standart vaqti", "ACST": "Markaziy Avstraliya standart vaqti", "LHDT": "Lord-Xau yozgi vaqti", "HNPM": "Sen-Pyer va Mikelon standart vaqti", "AWDT": "G‘arbiy Avstraliya yozgi vaqti", "CST": "Markaziy Amerika standart vaqti", "HEOG": "G‘arbiy Grenlandiya yozgi vaqti", "∅∅∅": "Azor orollari yozgi vaqti", "WIT": "Sharqiy Indoneziya vaqti", "GMT": "Grinvich o‘rtacha vaqti", "BOT": "Boliviya vaqti", "JST": "Yaponiya standart vaqti", "NZDT": "Yangi Zelandiya yozgi vaqti", "AKST": "Alyaska standart vaqti", "ACWDT": "Markaziy Avstraliya g‘arbiy yozgi vaqti", "CLT": "Chili standart vaqti", "COST": "Kolumbiya yozgi vaqti", "WIB": "Gʻarbiy Indoneziya vaqti", "WARST": "Gʻarbiy Argentina yozgi vaqti", "MST": "MST", "AEDT": "Sharqiy Avstraliya yozgi vaqti", "SGT": "Singapur vaqti", "GYT": "Gayana vaqti", "HNCU": "Kuba standart vaqti", "AWST": "G‘arbiy Avstraliya standart vaqti", "AST": "Atlantika standart vaqti", "AKDT": "Alyaska yozgi vaqti", "MEZ": "Markaziy Yevropa standart vaqti", "MESZ": "Markaziy Yevropa yozgi vaqti", "WART": "Gʻarbiy Argentina standart vaqti", "HNT": "Nyufaundlend standart vaqti", "HENOMX": "Shimoli-g‘arbiy Meksika yozgi vaqti", "PDT": "Tinch okeani yozgi vaqti", "MYT": "Malayziya vaqti", "GFT": "Fransuz Gvianasi vaqti", "EDT": "Sharqiy Amerika yozgi vaqti", "VET": "Venesuela vaqti", "TMT": "Turkmaniston standart vaqti", "PST": "Tinch okeani standart vaqti", "SAST": "Janubiy Afrika standart vaqti", "HKT": "Gonkong standart vaqti", "EAT": "Sharqiy Afrika vaqti", "CHAST": "Chatem standart vaqti", "WAST": "Gʻarbiy Afrika yozgi vaqti", "BT": "Butan vaqti", "ACWST": "Markaziy Avstraliya g‘arbiy standart vaqti", "HEPM": "Sen-Pyer va Mikelon yozgi vaqti", "HAT": "Nyufaundlend yozgi vaqti", "TMST": "Turkmaniston yozgi vaqti", "HECU": "Kuba yozgi vaqti", "SRT": "Surinam vaqti", "JDT": "Yaponiya yozgi vaqti", "NZST": "Yangi Zelandiya standart vaqti", "EST": "Sharqiy Amerika standart vaqti", "WITA": "Markaziy Indoneziya vaqti", "HNNOMX": "Shimoli-g‘arbiy Meksika standart vaqti", "CDT": "Markaziy Amerika yozgi vaqti", "WAT": "Gʻarbiy Afrika standart 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. // Decimal returns the decimal point of number
  169. func (uz *uz) Decimal() string {
  170. return uz.decimal
  171. }
  172. // Group returns the group of number
  173. func (uz *uz) Group() string {
  174. return uz.group
  175. }
  176. // Group returns the minus sign of number
  177. func (uz *uz) Minus() string {
  178. return uz.minus
  179. }
  180. // FmtNumber returns 'num' with digits/precision of 'v' for 'uz' and handles both Whole and Real numbers based on 'v'
  181. func (uz *uz) FmtNumber(num float64, v uint64) string {
  182. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  183. l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
  184. count := 0
  185. inWhole := v == 0
  186. b := make([]byte, 0, l)
  187. for i := len(s) - 1; i >= 0; i-- {
  188. if s[i] == '.' {
  189. b = append(b, uz.decimal[0])
  190. inWhole = true
  191. continue
  192. }
  193. if inWhole {
  194. if count == 3 {
  195. for j := len(uz.group) - 1; j >= 0; j-- {
  196. b = append(b, uz.group[j])
  197. }
  198. count = 1
  199. } else {
  200. count++
  201. }
  202. }
  203. b = append(b, s[i])
  204. }
  205. if num < 0 {
  206. b = append(b, uz.minus[0])
  207. }
  208. // reverse
  209. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  210. b[i], b[j] = b[j], b[i]
  211. }
  212. return string(b)
  213. }
  214. // FmtPercent returns 'num' with digits/precision of 'v' for 'uz' and handles both Whole and Real numbers based on 'v'
  215. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  216. func (uz *uz) FmtPercent(num float64, v uint64) string {
  217. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  218. l := len(s) + 3
  219. b := make([]byte, 0, l)
  220. for i := len(s) - 1; i >= 0; i-- {
  221. if s[i] == '.' {
  222. b = append(b, uz.decimal[0])
  223. continue
  224. }
  225. b = append(b, s[i])
  226. }
  227. if num < 0 {
  228. b = append(b, uz.minus[0])
  229. }
  230. // reverse
  231. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  232. b[i], b[j] = b[j], b[i]
  233. }
  234. b = append(b, uz.percent...)
  235. return string(b)
  236. }
  237. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'uz'
  238. func (uz *uz) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  239. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  240. symbol := uz.currencies[currency]
  241. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  242. count := 0
  243. inWhole := v == 0
  244. b := make([]byte, 0, l)
  245. for i := len(s) - 1; i >= 0; i-- {
  246. if s[i] == '.' {
  247. b = append(b, uz.decimal[0])
  248. inWhole = true
  249. continue
  250. }
  251. if inWhole {
  252. if count == 3 {
  253. for j := len(uz.group) - 1; j >= 0; j-- {
  254. b = append(b, uz.group[j])
  255. }
  256. count = 1
  257. } else {
  258. count++
  259. }
  260. }
  261. b = append(b, s[i])
  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. b = append(b, uz.currencyPositiveSuffix...)
  279. b = append(b, symbol...)
  280. return string(b)
  281. }
  282. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'uz'
  283. // in accounting notation.
  284. func (uz *uz) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  285. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  286. symbol := uz.currencies[currency]
  287. l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  288. count := 0
  289. inWhole := v == 0
  290. b := make([]byte, 0, l)
  291. for i := len(s) - 1; i >= 0; i-- {
  292. if s[i] == '.' {
  293. b = append(b, uz.decimal[0])
  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. b = append(b, uz.minus[0])
  311. }
  312. // reverse
  313. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  314. b[i], b[j] = b[j], b[i]
  315. }
  316. if int(v) < 2 {
  317. if v == 0 {
  318. b = append(b, uz.decimal...)
  319. }
  320. for i := 0; i < 2-int(v); i++ {
  321. b = append(b, '0')
  322. }
  323. }
  324. if num < 0 {
  325. b = append(b, uz.currencyNegativeSuffix...)
  326. b = append(b, symbol...)
  327. } else {
  328. b = append(b, uz.currencyPositiveSuffix...)
  329. b = append(b, symbol...)
  330. }
  331. return string(b)
  332. }
  333. // FmtDateShort returns the short date representation of 't' for 'uz'
  334. func (uz *uz) FmtDateShort(t time.Time) string {
  335. b := make([]byte, 0, 32)
  336. if t.Day() < 10 {
  337. b = append(b, '0')
  338. }
  339. b = strconv.AppendInt(b, int64(t.Day()), 10)
  340. b = append(b, []byte{0x2f}...)
  341. if t.Month() < 10 {
  342. b = append(b, '0')
  343. }
  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 'uz'
  354. func (uz *uz) 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{0x2d}...)
  358. b = append(b, uz.monthsAbbreviated[t.Month()]...)
  359. b = append(b, []byte{0x2c, 0x20}...)
  360. if t.Year() > 0 {
  361. b = strconv.AppendInt(b, int64(t.Year()), 10)
  362. } else {
  363. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  364. }
  365. return string(b)
  366. }
  367. // FmtDateLong returns the long date representation of 't' for 'uz'
  368. func (uz *uz) FmtDateLong(t time.Time) string {
  369. b := make([]byte, 0, 32)
  370. b = strconv.AppendInt(b, int64(t.Day()), 10)
  371. b = append(b, []byte{0x2d}...)
  372. b = append(b, uz.monthsWide[t.Month()]...)
  373. b = append(b, []byte{0x2c, 0x20}...)
  374. if t.Year() > 0 {
  375. b = strconv.AppendInt(b, int64(t.Year()), 10)
  376. } else {
  377. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  378. }
  379. return string(b)
  380. }
  381. // FmtDateFull returns the full date representation of 't' for 'uz'
  382. func (uz *uz) FmtDateFull(t time.Time) string {
  383. b := make([]byte, 0, 32)
  384. b = append(b, uz.daysWide[t.Weekday()]...)
  385. b = append(b, []byte{0x2c, 0x20}...)
  386. b = strconv.AppendInt(b, int64(t.Day()), 10)
  387. b = append(b, []byte{0x2d}...)
  388. b = append(b, uz.monthsWide[t.Month()]...)
  389. b = append(b, []byte{0x2c, 0x20}...)
  390. if t.Year() > 0 {
  391. b = strconv.AppendInt(b, int64(t.Year()), 10)
  392. } else {
  393. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  394. }
  395. return string(b)
  396. }
  397. // FmtTimeShort returns the short time representation of 't' for 'uz'
  398. func (uz *uz) FmtTimeShort(t time.Time) string {
  399. b := make([]byte, 0, 32)
  400. if t.Hour() < 10 {
  401. b = append(b, '0')
  402. }
  403. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  404. b = append(b, uz.timeSeparator...)
  405. if t.Minute() < 10 {
  406. b = append(b, '0')
  407. }
  408. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  409. return string(b)
  410. }
  411. // FmtTimeMedium returns the medium time representation of 't' for 'uz'
  412. func (uz *uz) FmtTimeMedium(t time.Time) string {
  413. b := make([]byte, 0, 32)
  414. if t.Hour() < 10 {
  415. b = append(b, '0')
  416. }
  417. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  418. b = append(b, uz.timeSeparator...)
  419. if t.Minute() < 10 {
  420. b = append(b, '0')
  421. }
  422. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  423. b = append(b, uz.timeSeparator...)
  424. if t.Second() < 10 {
  425. b = append(b, '0')
  426. }
  427. b = strconv.AppendInt(b, int64(t.Second()), 10)
  428. return string(b)
  429. }
  430. // FmtTimeLong returns the long time representation of 't' for 'uz'
  431. func (uz *uz) FmtTimeLong(t time.Time) string {
  432. b := make([]byte, 0, 32)
  433. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  434. b = append(b, uz.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, uz.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, 0x28}...)
  445. tz, _ := t.Zone()
  446. b = append(b, tz...)
  447. b = append(b, []byte{0x29}...)
  448. return string(b)
  449. }
  450. // FmtTimeFull returns the full time representation of 't' for 'uz'
  451. func (uz *uz) FmtTimeFull(t time.Time) string {
  452. b := make([]byte, 0, 32)
  453. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  454. b = append(b, uz.timeSeparator...)
  455. if t.Minute() < 10 {
  456. b = append(b, '0')
  457. }
  458. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  459. b = append(b, uz.timeSeparator...)
  460. if t.Second() < 10 {
  461. b = append(b, '0')
  462. }
  463. b = strconv.AppendInt(b, int64(t.Second()), 10)
  464. b = append(b, []byte{0x20, 0x28}...)
  465. tz, _ := t.Zone()
  466. if btz, ok := uz.timezones[tz]; ok {
  467. b = append(b, btz...)
  468. } else {
  469. b = append(b, tz...)
  470. }
  471. b = append(b, []byte{0x29}...)
  472. return string(b)
  473. }