sr_Latn.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  1. package sr_Latn
  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_Latn 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_Latn' locale
  42. func New() locales.Translator {
  43. return &sr_Latn{
  44. locale: "sr_Latn",
  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", "KM", "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", "¥", "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", "MX$", "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", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "VND", "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"},
  56. currencyPositiveSuffix: " ",
  57. currencyNegativePrefix: "(",
  58. currencyNegativeSuffix: " )",
  59. monthsAbbreviated: []string{"", "jan", "feb", "mar", "apr", "maj", "jun", "jul", "avg", "sep", "okt", "nov", "dec"},
  60. monthsNarrow: []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"},
  61. monthsWide: []string{"", "januar", "februar", "mart", "april", "maj", "jun", "jul", "avgust", "septembar", "oktobar", "novembar", "decembar"},
  62. daysAbbreviated: []string{"ned", "pon", "uto", "sre", "čet", "pet", "sub"},
  63. daysNarrow: []string{"n", "p", "u", "s", "č", "p", "s"},
  64. daysShort: []string{"ne", "po", "ut", "sr", "če", "pe", "su"},
  65. daysWide: []string{"nedelja", "ponedeljak", "utorak", "sreda", "četvrtak", "petak", "subota"},
  66. periodsAbbreviated: []string{"pre podne", "po podne"},
  67. periodsNarrow: []string{"a", "p"},
  68. periodsWide: []string{"pre podne", "po podne"},
  69. erasAbbreviated: []string{"p. n. e.", "n. e."},
  70. erasNarrow: []string{"p.n.e.", "n.e."},
  71. erasWide: []string{"pre nove ere", "nove ere"},
  72. timezones: map[string]string{"∅∅∅": "Amazon, letnje vreme", "CAT": "Centralno-afričko vreme", "UYT": "Urugvaj, standardno vreme", "ChST": "Čamoro vreme", "ACDT": "Australijsko centralno letnje vreme", "HKT": "Hong Kong, standardno vreme", "HEPM": "Sen Pjer i Mikelon, letnje vreme", "MST": "Makao standardno vreme", "UYST": "Urugvaj, letnje vreme", "HNPMX": "Meksički Pacifik, standardno vreme", "WESZ": "Zapadnoevropsko letnje vreme", "HNPM": "Sen Pjer i Mikelon, standardno vreme", "ART": "Argentina, standardno vreme", "CLT": "Čile, standardno vreme", "CLST": "Čile, letnje vreme", "WIT": "Istočno-indonezijsko vreme", "COST": "Kolumbija, letnje vreme", "AWDT": "Australijsko zapadno letnje vreme", "AKST": "Aljaska, standardno vreme", "EDT": "Severnoameričko istočno letnje vreme", "SRT": "Surinam vreme", "CST": "Severnoameričko centralno standardno vreme", "JST": "Japansko standardno vreme", "HEOG": "Zapadni Grenland, letnje vreme", "HNNOMX": "Severozapadni Meksiko, standardno vreme", "HAST": "Havajsko-aleutsko standardno vreme", "AST": "Atlantsko standardno vreme", "HEEG": "Istočni Grenland, letnje vreme", "LHST": "Lord Hov, standardno vreme", "HNCU": "Kuba, standardno vreme", "NZDT": "Novi Zeland, letnje vreme", "MESZ": "Srednjeevropsko letnje vreme", "BT": "Butan vreme", "HKST": "Hong Kong, letnje vreme", "WITA": "Centralno-indonezijsko vreme", "ECT": "Ekvador vreme", "HNEG": "Istočni Grenland, standardno vreme", "HAT": "Njufaundlend, letnje vreme", "VET": "Venecuela vreme", "ADT": "Atlantsko letnje vreme", "COT": "Kolumbija, standardno vreme", "CHADT": "Čatam, letnje vreme", "HECU": "Kuba, letnje vreme", "AEDT": "Australijsko istočno letnje vreme", "GFT": "Francuska Gvajana vreme", "WARST": "Zapadna Argentina, letnje vreme", "HNT": "Njufaundlend, standardno vreme", "MDT": "Makao letnje računanje vremena", "GYT": "Gvajana vreme", "HEPMX": "Meksički Pacifik, letnje vreme", "WAST": "Zapadno-afričko letnje vreme", "JDT": "Japansko letnje vreme", "EST": "Severnoameričko istočno standardno vreme", "MEZ": "Srednjeevropsko standardno vreme", "TMT": "Turkmenistan, standardno vreme", "OESZ": "Istočnoevropsko letnje vreme", "ARST": "Argentina, letnje vreme", "GMT": "Srednje vreme po Griniču", "PST": "Severnoameričko pacifičko standardno vreme", "NZST": "Novi Zeland, standardno vreme", "HENOMX": "Severozapadni Meksiko, letnje vreme", "OEZ": "Istočnoevropsko standardno vreme", "AWST": "Australijsko zapadno standardno vreme", "WIB": "Zapadno-indonezijsko vreme", "HNOG": "Zapadni Grenland, standardno vreme", "IST": "Indijsko standardno vreme", "EAT": "Istočno-afričko vreme", "PDT": "Severnoameričko pacifičko letnje vreme", "AEST": "Australijsko istočno standardno vreme", "WAT": "Zapadno-afričko standardno vreme", "ACWST": "Australijsko centralno zapadno standardno vreme", "WART": "Zapadna Argentina, standardno vreme", "TMST": "Turkmenistan, letnje vreme", "CDT": "Severnoameričko centralno letnje vreme", "SAST": "Južno-afričko vreme", "MYT": "Malezija vreme", "SGT": "Singapur, standardno vreme", "ACST": "Australijsko centralno standardno vreme", "LHDT": "Lord Hov, letnje vreme", "CHAST": "Čatam, standardno vreme", "WEZ": "Zapadnoevropsko standardno vreme", "BOT": "Bolivija vreme", "AKDT": "Aljaska, letnje vreme", "ACWDT": "Australijsko centralno zapadno letnje vreme", "HADT": "Havajsko-aleutsko letnje vreme"},
  73. }
  74. }
  75. // Locale returns the current translators string locale
  76. func (sr *sr_Latn) Locale() string {
  77. return sr.locale
  78. }
  79. // PluralsCardinal returns the list of cardinal plural rules associated with 'sr_Latn'
  80. func (sr *sr_Latn) PluralsCardinal() []locales.PluralRule {
  81. return sr.pluralsCardinal
  82. }
  83. // PluralsOrdinal returns the list of ordinal plural rules associated with 'sr_Latn'
  84. func (sr *sr_Latn) PluralsOrdinal() []locales.PluralRule {
  85. return sr.pluralsOrdinal
  86. }
  87. // PluralsRange returns the list of range plural rules associated with 'sr_Latn'
  88. func (sr *sr_Latn) PluralsRange() []locales.PluralRule {
  89. return sr.pluralsRange
  90. }
  91. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sr_Latn'
  92. func (sr *sr_Latn) 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_Latn'
  108. func (sr *sr_Latn) 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_Latn'
  112. func (sr *sr_Latn) 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_Latn) MonthAbbreviated(month time.Month) string {
  136. return sr.monthsAbbreviated[month]
  137. }
  138. // MonthsAbbreviated returns the locales abbreviated months
  139. func (sr *sr_Latn) MonthsAbbreviated() []string {
  140. return sr.monthsAbbreviated[1:]
  141. }
  142. // MonthNarrow returns the locales narrow month given the 'month' provided
  143. func (sr *sr_Latn) MonthNarrow(month time.Month) string {
  144. return sr.monthsNarrow[month]
  145. }
  146. // MonthsNarrow returns the locales narrow months
  147. func (sr *sr_Latn) MonthsNarrow() []string {
  148. return sr.monthsNarrow[1:]
  149. }
  150. // MonthWide returns the locales wide month given the 'month' provided
  151. func (sr *sr_Latn) MonthWide(month time.Month) string {
  152. return sr.monthsWide[month]
  153. }
  154. // MonthsWide returns the locales wide months
  155. func (sr *sr_Latn) MonthsWide() []string {
  156. return sr.monthsWide[1:]
  157. }
  158. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  159. func (sr *sr_Latn) WeekdayAbbreviated(weekday time.Weekday) string {
  160. return sr.daysAbbreviated[weekday]
  161. }
  162. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  163. func (sr *sr_Latn) WeekdaysAbbreviated() []string {
  164. return sr.daysAbbreviated
  165. }
  166. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  167. func (sr *sr_Latn) WeekdayNarrow(weekday time.Weekday) string {
  168. return sr.daysNarrow[weekday]
  169. }
  170. // WeekdaysNarrow returns the locales narrow weekdays
  171. func (sr *sr_Latn) WeekdaysNarrow() []string {
  172. return sr.daysNarrow
  173. }
  174. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  175. func (sr *sr_Latn) WeekdayShort(weekday time.Weekday) string {
  176. return sr.daysShort[weekday]
  177. }
  178. // WeekdaysShort returns the locales short weekdays
  179. func (sr *sr_Latn) WeekdaysShort() []string {
  180. return sr.daysShort
  181. }
  182. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  183. func (sr *sr_Latn) WeekdayWide(weekday time.Weekday) string {
  184. return sr.daysWide[weekday]
  185. }
  186. // WeekdaysWide returns the locales wide weekdays
  187. func (sr *sr_Latn) WeekdaysWide() []string {
  188. return sr.daysWide
  189. }
  190. // Decimal returns the decimal point of number
  191. func (sr *sr_Latn) Decimal() string {
  192. return sr.decimal
  193. }
  194. // Group returns the group of number
  195. func (sr *sr_Latn) Group() string {
  196. return sr.group
  197. }
  198. // Group returns the minus sign of number
  199. func (sr *sr_Latn) Minus() string {
  200. return sr.minus
  201. }
  202. // FmtNumber returns 'num' with digits/precision of 'v' for 'sr_Latn' and handles both Whole and Real numbers based on 'v'
  203. func (sr *sr_Latn) 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_Latn' 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_Latn) 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_Latn'
  258. func (sr *sr_Latn) 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_Latn'
  301. // in accounting notation.
  302. func (sr *sr_Latn) 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_Latn'
  350. func (sr *sr_Latn) 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_Latn'
  365. func (sr *sr_Latn) 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_Latn'
  386. func (sr *sr_Latn) 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_Latn'
  404. func (sr *sr_Latn) 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_Latn'
  424. func (sr *sr_Latn) 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_Latn'
  438. func (sr *sr_Latn) 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_Latn'
  457. func (sr *sr_Latn) 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_Latn'
  479. func (sr *sr_Latn) 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. }