sr_Cyrl.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. package sr_Cyrl
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type sr_Cyrl 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. currencyNegativePrefix string
  24. currencyNegativeSuffix string
  25. monthsAbbreviated []string
  26. monthsNarrow []string
  27. monthsWide []string
  28. daysAbbreviated []string
  29. daysNarrow []string
  30. daysShort []string
  31. daysWide []string
  32. periodsAbbreviated []string
  33. periodsNarrow []string
  34. periodsShort []string
  35. periodsWide []string
  36. erasAbbreviated []string
  37. erasNarrow []string
  38. erasWide []string
  39. timezones map[string]string
  40. }
  41. // New returns a new instance of translator for the 'sr_Cyrl' locale
  42. func New() locales.Translator {
  43. return &sr_Cyrl{
  44. locale: "sr_Cyrl",
  45. pluralsCardinal: []locales.PluralRule{2, 4, 6},
  46. pluralsOrdinal: []locales.PluralRule{6},
  47. pluralsRange: []locales.PluralRule{2, 4, 6},
  48. decimal: ",",
  49. group: ".",
  50. minus: "-",
  51. percent: "%",
  52. perMille: "‰",
  53. timeSeparator: ":",
  54. inifinity: "∞",
  55. 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"},
  56. currencyPositiveSuffix: " ",
  57. currencyNegativePrefix: "(",
  58. currencyNegativeSuffix: " )",
  59. monthsAbbreviated: []string{"", "јан", "феб", "мар", "апр", "мај", "јун", "јул", "авг", "сеп", "окт", "нов", "дец"},
  60. monthsNarrow: []string{"", "ј", "ф", "м", "а", "м", "ј", "ј", "а", "с", "о", "н", "д"},
  61. monthsWide: []string{"", "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"},
  62. daysAbbreviated: []string{"нед", "пон", "уто", "сре", "чет", "пет", "суб"},
  63. daysNarrow: []string{"н", "п", "у", "с", "ч", "п", "с"},
  64. daysShort: []string{"не", "по", "ут", "ср", "че", "пе", "су"},
  65. daysWide: []string{"недеља", "понедељак", "уторак", "среда", "четвртак", "петак", "субота"},
  66. periodsAbbreviated: []string{"пре подне", "по подне"},
  67. periodsNarrow: []string{"a", "p"},
  68. periodsWide: []string{"пре подне", "по подне"},
  69. erasAbbreviated: []string{"п. н. е.", "н. е."},
  70. erasNarrow: []string{"п.н.е.", "н.е."},
  71. erasWide: []string{"пре нове ере", "нове ере"},
  72. timezones: map[string]string{"PDT": "Северноамеричко пацифичко летње време", "HEEG": "Источни Гренланд, летње време", "OEZ": "Источноевропско стандардно време", "WESZ": "Западноевропско летње време", "NZST": "Нови Зеланд, стандардно време", "EDT": "Северноамеричко источно летње време", "WART": "Западна Аргентина, стандардно време", "TMST": "Туркменистан, летње време", "GMT": "Средње време по Гриничу", "AWST": "Аустралијско западно стандардно време", "BOT": "Боливија време", "SGT": "Сингапур, стандардно време", "ACST": "Аустралијско централно стандардно време", "ACWST": "Аустралијско централно западно стандардно време", "WARST": "Западна Аргентина, летње време", "∅∅∅": "Амазон, летње време", "UYST": "Уругвај, летње време", "HNCU": "Куба, стандардно време", "IST": "Индијско стандардно време", "WITA": "Централно-индонезијско време", "CLST": "Чиле, летње време", "HEPM": "Сен Пјер и Микелон, летње време", "TMT": "Туркменистан, стандардно време", "CST": "Северноамеричко централно стандардно време", "PST": "Северноамеричко пацифичко стандардно време", "AEDT": "Аустралијско источно летње време", "MDT": "Северноамеричко планинско летње време", "JST": "Јапанско стандардно време", "HAT": "Њуфаундленд, летње време", "HNNOMX": "Северозападни Мексико, стандардно време", "CAT": "Централно-афричко време", "HADT": "Хавајско-алеутско летње време", "GYT": "Гвајана време", "AST": "Атлантско стандардно време", "ADT": "Атлантско летње време", "MYT": "Малезија време", "EST": "Северноамеричко источно стандардно време", "HNPM": "Сен Пјер и Микелон, стандардно време", "HAST": "Хавајско-алеутско стандардно време", "ChST": "Чаморо време", "CDT": "Северноамеричко централно летње време", "AEST": "Аустралијско источно стандардно време", "JDT": "Јапанско летње време", "CLT": "Чиле, стандардно време", "HNOG": "Западни Гренланд, стандардно време", "MESZ": "Средњеевропско летње време", "ARST": "Аргентина, летње време", "COT": "Колумбија, стандардно време", "UYT": "Уругвај, стандардно време", "AWDT": "Аустралијско западно летње време", "HNPMX": "Мексички Пацифик, стандардно време", "SAST": "Јужно-афричко време", "WAST": "Западно-афричко летње време", "AKDT": "Аљаска, летње време", "OESZ": "Источноевропско летње време", "ACWDT": "Аустралијско централно западно летње време", "HKST": "Хонг Конг, летње време", "ACDT": "Аустралијско централно летње време", "WEZ": "Западноевропско стандардно време", "GFT": "Француска Гвајана време", "ECT": "Еквадор време", "HEOG": "Западни Гренланд, летње време", "LHST": "Лорд Хов, стандардно време", "ART": "Аргентина, стандардно време", "BT": "Бутан време", "NZDT": "Нови Зеланд, летње време", "HKT": "Хонг Конг, стандардно време", "LHDT": "Лорд Хов, летње време", "WIT": "Источно-индонезијско време", "WAT": "Западно-афричко стандардно време", "MEZ": "Средњеевропско стандардно време", "HECU": "Куба, летње време", "AKST": "Аљаска, стандардно време", "HNT": "Њуфаундленд, стандардно време", "COST": "Колумбија, летње време", "CHADT": "Чатам, летње време", "HEPMX": "Мексички Пацифик, летње време", "WIB": "Западно-индонезијско време", "HENOMX": "Северозападни Мексико, летње време", "CHAST": "Чатам, стандардно време", "MST": "Северноамеричко планинско стандардно време", "HNEG": "Источни Гренланд, стандардно време", "VET": "Венецуела време", "SRT": "Суринам време", "EAT": "Источно-афричко време"},
  73. }
  74. }
  75. // Locale returns the current translators string locale
  76. func (sr *sr_Cyrl) Locale() string {
  77. return sr.locale
  78. }
  79. // PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Cyrl'
  80. func (sr *sr_Cyrl) PluralsCardinal() []locales.PluralRule {
  81. return sr.pluralsCardinal
  82. }
  83. // PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Cyrl'
  84. func (sr *sr_Cyrl) PluralsOrdinal() []locales.PluralRule {
  85. return sr.pluralsOrdinal
  86. }
  87. // PluralsRange returns the list of range plural rules associated with 'sr_Cyrl'
  88. func (sr *sr_Cyrl) PluralsRange() []locales.PluralRule {
  89. return sr.pluralsRange
  90. }
  91. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl'
  92. func (sr *sr_Cyrl) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  93. n := math.Abs(num)
  94. i := int64(n)
  95. f := locales.F(n, v)
  96. iMod10 := i % 10
  97. iMod100 := i % 100
  98. fMod10 := f % 10
  99. fMod100 := f % 100
  100. if (v == 0 && iMod10 == 1 && iMod100 != 11) || (fMod10 == 1 && fMod100 != 11) {
  101. return locales.PluralRuleOne
  102. } else if (v == 0 && iMod10 >= 2 && iMod10 <= 4 && (iMod100 < 12 || iMod100 > 14)) || (fMod10 >= 2 && fMod10 <= 4 && (fMod100 < 12 || fMod100 > 14)) {
  103. return locales.PluralRuleFew
  104. }
  105. return locales.PluralRuleOther
  106. }
  107. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Cyrl'
  108. func (sr *sr_Cyrl) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  109. return locales.PluralRuleOther
  110. }
  111. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'sr_Cyrl'
  112. func (sr *sr_Cyrl) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  113. start := sr.CardinalPluralRule(num1, v1)
  114. end := sr.CardinalPluralRule(num2, v2)
  115. if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
  116. return locales.PluralRuleOne
  117. } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
  118. return locales.PluralRuleFew
  119. } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  120. return locales.PluralRuleOther
  121. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
  122. return locales.PluralRuleOne
  123. } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
  124. return locales.PluralRuleFew
  125. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
  126. return locales.PluralRuleOther
  127. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  128. return locales.PluralRuleOne
  129. } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
  130. return locales.PluralRuleFew
  131. }
  132. return locales.PluralRuleOther
  133. }
  134. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  135. func (sr *sr_Cyrl) MonthAbbreviated(month time.Month) string {
  136. return sr.monthsAbbreviated[month]
  137. }
  138. // MonthsAbbreviated returns the locales abbreviated months
  139. func (sr *sr_Cyrl) MonthsAbbreviated() []string {
  140. return sr.monthsAbbreviated[1:]
  141. }
  142. // MonthNarrow returns the locales narrow month given the 'month' provided
  143. func (sr *sr_Cyrl) MonthNarrow(month time.Month) string {
  144. return sr.monthsNarrow[month]
  145. }
  146. // MonthsNarrow returns the locales narrow months
  147. func (sr *sr_Cyrl) MonthsNarrow() []string {
  148. return sr.monthsNarrow[1:]
  149. }
  150. // MonthWide returns the locales wide month given the 'month' provided
  151. func (sr *sr_Cyrl) MonthWide(month time.Month) string {
  152. return sr.monthsWide[month]
  153. }
  154. // MonthsWide returns the locales wide months
  155. func (sr *sr_Cyrl) MonthsWide() []string {
  156. return sr.monthsWide[1:]
  157. }
  158. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  159. func (sr *sr_Cyrl) WeekdayAbbreviated(weekday time.Weekday) string {
  160. return sr.daysAbbreviated[weekday]
  161. }
  162. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  163. func (sr *sr_Cyrl) WeekdaysAbbreviated() []string {
  164. return sr.daysAbbreviated
  165. }
  166. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  167. func (sr *sr_Cyrl) WeekdayNarrow(weekday time.Weekday) string {
  168. return sr.daysNarrow[weekday]
  169. }
  170. // WeekdaysNarrow returns the locales narrow weekdays
  171. func (sr *sr_Cyrl) WeekdaysNarrow() []string {
  172. return sr.daysNarrow
  173. }
  174. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  175. func (sr *sr_Cyrl) WeekdayShort(weekday time.Weekday) string {
  176. return sr.daysShort[weekday]
  177. }
  178. // WeekdaysShort returns the locales short weekdays
  179. func (sr *sr_Cyrl) WeekdaysShort() []string {
  180. return sr.daysShort
  181. }
  182. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  183. func (sr *sr_Cyrl) WeekdayWide(weekday time.Weekday) string {
  184. return sr.daysWide[weekday]
  185. }
  186. // WeekdaysWide returns the locales wide weekdays
  187. func (sr *sr_Cyrl) WeekdaysWide() []string {
  188. return sr.daysWide
  189. }
  190. // Decimal returns the decimal point of number
  191. func (sr *sr_Cyrl) Decimal() string {
  192. return sr.decimal
  193. }
  194. // Group returns the group of number
  195. func (sr *sr_Cyrl) Group() string {
  196. return sr.group
  197. }
  198. // Group returns the minus sign of number
  199. func (sr *sr_Cyrl) Minus() string {
  200. return sr.minus
  201. }
  202. // FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Cyrl' and handles both Whole and Real numbers based on 'v'
  203. func (sr *sr_Cyrl) FmtNumber(num float64, v uint64) string {
  204. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  205. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  206. count := 0
  207. inWhole := v == 0
  208. b := make([]byte, 0, l)
  209. for i := len(s) - 1; i >= 0; i-- {
  210. if s[i] == '.' {
  211. b = append(b, sr.decimal[0])
  212. inWhole = true
  213. continue
  214. }
  215. if inWhole {
  216. if count == 3 {
  217. b = append(b, sr.group[0])
  218. count = 1
  219. } else {
  220. count++
  221. }
  222. }
  223. b = append(b, s[i])
  224. }
  225. if num < 0 {
  226. b = append(b, sr.minus[0])
  227. }
  228. // reverse
  229. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  230. b[i], b[j] = b[j], b[i]
  231. }
  232. return string(b)
  233. }
  234. // FmtPercent returns 'num' with digits/precision of 'v' for 'sr_Cyrl' and handles both Whole and Real numbers based on 'v'
  235. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  236. func (sr *sr_Cyrl) FmtPercent(num float64, v uint64) string {
  237. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  238. l := len(s) + 3
  239. b := make([]byte, 0, l)
  240. for i := len(s) - 1; i >= 0; i-- {
  241. if s[i] == '.' {
  242. b = append(b, sr.decimal[0])
  243. continue
  244. }
  245. b = append(b, s[i])
  246. }
  247. if num < 0 {
  248. b = append(b, sr.minus[0])
  249. }
  250. // reverse
  251. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  252. b[i], b[j] = b[j], b[i]
  253. }
  254. b = append(b, sr.percent...)
  255. return string(b)
  256. }
  257. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl'
  258. func (sr *sr_Cyrl) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  259. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  260. symbol := sr.currencies[currency]
  261. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  262. count := 0
  263. inWhole := v == 0
  264. b := make([]byte, 0, l)
  265. for i := len(s) - 1; i >= 0; i-- {
  266. if s[i] == '.' {
  267. b = append(b, sr.decimal[0])
  268. inWhole = true
  269. continue
  270. }
  271. if inWhole {
  272. if count == 3 {
  273. b = append(b, sr.group[0])
  274. count = 1
  275. } else {
  276. count++
  277. }
  278. }
  279. b = append(b, s[i])
  280. }
  281. if num < 0 {
  282. b = append(b, sr.minus[0])
  283. }
  284. // reverse
  285. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  286. b[i], b[j] = b[j], b[i]
  287. }
  288. if int(v) < 2 {
  289. if v == 0 {
  290. b = append(b, sr.decimal...)
  291. }
  292. for i := 0; i < 2-int(v); i++ {
  293. b = append(b, '0')
  294. }
  295. }
  296. b = append(b, sr.currencyPositiveSuffix...)
  297. b = append(b, symbol...)
  298. return string(b)
  299. }
  300. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sr_Cyrl'
  301. // in accounting notation.
  302. func (sr *sr_Cyrl) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  303. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  304. symbol := sr.currencies[currency]
  305. l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3
  306. count := 0
  307. inWhole := v == 0
  308. b := make([]byte, 0, l)
  309. for i := len(s) - 1; i >= 0; i-- {
  310. if s[i] == '.' {
  311. b = append(b, sr.decimal[0])
  312. inWhole = true
  313. continue
  314. }
  315. if inWhole {
  316. if count == 3 {
  317. b = append(b, sr.group[0])
  318. count = 1
  319. } else {
  320. count++
  321. }
  322. }
  323. b = append(b, s[i])
  324. }
  325. if num < 0 {
  326. b = append(b, sr.currencyNegativePrefix[0])
  327. }
  328. // reverse
  329. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  330. b[i], b[j] = b[j], b[i]
  331. }
  332. if int(v) < 2 {
  333. if v == 0 {
  334. b = append(b, sr.decimal...)
  335. }
  336. for i := 0; i < 2-int(v); i++ {
  337. b = append(b, '0')
  338. }
  339. }
  340. if num < 0 {
  341. b = append(b, sr.currencyNegativeSuffix...)
  342. b = append(b, symbol...)
  343. } else {
  344. b = append(b, sr.currencyPositiveSuffix...)
  345. b = append(b, symbol...)
  346. }
  347. return string(b)
  348. }
  349. // FmtDateShort returns the short date representation of 't' for 'sr_Cyrl'
  350. func (sr *sr_Cyrl) FmtDateShort(t time.Time) string {
  351. b := make([]byte, 0, 32)
  352. b = strconv.AppendInt(b, int64(t.Day()), 10)
  353. b = append(b, []byte{0x2e}...)
  354. b = strconv.AppendInt(b, int64(t.Month()), 10)
  355. b = append(b, []byte{0x2e}...)
  356. if t.Year() > 9 {
  357. b = append(b, strconv.Itoa(t.Year())[2:]...)
  358. } else {
  359. b = append(b, strconv.Itoa(t.Year())[1:]...)
  360. }
  361. b = append(b, []byte{0x2e}...)
  362. return string(b)
  363. }
  364. // FmtDateMedium returns the medium date representation of 't' for 'sr_Cyrl'
  365. func (sr *sr_Cyrl) FmtDateMedium(t time.Time) string {
  366. b := make([]byte, 0, 32)
  367. if t.Day() < 10 {
  368. b = append(b, '0')
  369. }
  370. b = strconv.AppendInt(b, int64(t.Day()), 10)
  371. b = append(b, []byte{0x2e}...)
  372. if t.Month() < 10 {
  373. b = append(b, '0')
  374. }
  375. b = strconv.AppendInt(b, int64(t.Month()), 10)
  376. b = append(b, []byte{0x2e}...)
  377. if t.Year() > 0 {
  378. b = strconv.AppendInt(b, int64(t.Year()), 10)
  379. } else {
  380. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  381. }
  382. b = append(b, []byte{0x2e}...)
  383. return string(b)
  384. }
  385. // FmtDateLong returns the long date representation of 't' for 'sr_Cyrl'
  386. func (sr *sr_Cyrl) FmtDateLong(t time.Time) string {
  387. b := make([]byte, 0, 32)
  388. if t.Day() < 10 {
  389. b = append(b, '0')
  390. }
  391. b = strconv.AppendInt(b, int64(t.Day()), 10)
  392. b = append(b, []byte{0x2e, 0x20}...)
  393. b = append(b, sr.monthsWide[t.Month()]...)
  394. b = append(b, []byte{0x20}...)
  395. if t.Year() > 0 {
  396. b = strconv.AppendInt(b, int64(t.Year()), 10)
  397. } else {
  398. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  399. }
  400. b = append(b, []byte{0x2e}...)
  401. return string(b)
  402. }
  403. // FmtDateFull returns the full date representation of 't' for 'sr_Cyrl'
  404. func (sr *sr_Cyrl) FmtDateFull(t time.Time) string {
  405. b := make([]byte, 0, 32)
  406. b = append(b, sr.daysWide[t.Weekday()]...)
  407. b = append(b, []byte{0x2c, 0x20}...)
  408. if t.Day() < 10 {
  409. b = append(b, '0')
  410. }
  411. b = strconv.AppendInt(b, int64(t.Day()), 10)
  412. b = append(b, []byte{0x2e, 0x20}...)
  413. b = append(b, sr.monthsWide[t.Month()]...)
  414. b = append(b, []byte{0x20}...)
  415. if t.Year() > 0 {
  416. b = strconv.AppendInt(b, int64(t.Year()), 10)
  417. } else {
  418. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  419. }
  420. b = append(b, []byte{0x2e}...)
  421. return string(b)
  422. }
  423. // FmtTimeShort returns the short time representation of 't' for 'sr_Cyrl'
  424. func (sr *sr_Cyrl) FmtTimeShort(t time.Time) string {
  425. b := make([]byte, 0, 32)
  426. if t.Hour() < 10 {
  427. b = append(b, '0')
  428. }
  429. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  430. b = append(b, sr.timeSeparator...)
  431. if t.Minute() < 10 {
  432. b = append(b, '0')
  433. }
  434. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  435. return string(b)
  436. }
  437. // FmtTimeMedium returns the medium time representation of 't' for 'sr_Cyrl'
  438. func (sr *sr_Cyrl) FmtTimeMedium(t time.Time) string {
  439. b := make([]byte, 0, 32)
  440. if t.Hour() < 10 {
  441. b = append(b, '0')
  442. }
  443. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  444. b = append(b, sr.timeSeparator...)
  445. if t.Minute() < 10 {
  446. b = append(b, '0')
  447. }
  448. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  449. b = append(b, sr.timeSeparator...)
  450. if t.Second() < 10 {
  451. b = append(b, '0')
  452. }
  453. b = strconv.AppendInt(b, int64(t.Second()), 10)
  454. return string(b)
  455. }
  456. // FmtTimeLong returns the long time representation of 't' for 'sr_Cyrl'
  457. func (sr *sr_Cyrl) FmtTimeLong(t time.Time) string {
  458. b := make([]byte, 0, 32)
  459. if t.Hour() < 10 {
  460. b = append(b, '0')
  461. }
  462. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  463. b = append(b, sr.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, sr.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. tz, _ := t.Zone()
  475. b = append(b, tz...)
  476. return string(b)
  477. }
  478. // FmtTimeFull returns the full time representation of 't' for 'sr_Cyrl'
  479. func (sr *sr_Cyrl) FmtTimeFull(t time.Time) string {
  480. b := make([]byte, 0, 32)
  481. if t.Hour() < 10 {
  482. b = append(b, '0')
  483. }
  484. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  485. b = append(b, sr.timeSeparator...)
  486. if t.Minute() < 10 {
  487. b = append(b, '0')
  488. }
  489. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  490. b = append(b, sr.timeSeparator...)
  491. if t.Second() < 10 {
  492. b = append(b, '0')
  493. }
  494. b = strconv.AppendInt(b, int64(t.Second()), 10)
  495. b = append(b, []byte{0x20}...)
  496. tz, _ := t.Zone()
  497. if btz, ok := sr.timezones[tz]; ok {
  498. b = append(b, btz...)
  499. } else {
  500. b = append(b, tz...)
  501. }
  502. return string(b)
  503. }