ro_MD.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. package ro_MD
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type ro_MD 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. percentSuffix string
  19. perMille string
  20. timeSeparator string
  21. inifinity string
  22. currencies []string // idx = enum of currency code
  23. currencyPositiveSuffix string
  24. currencyNegativePrefix string
  25. currencyNegativeSuffix string
  26. monthsAbbreviated []string
  27. monthsNarrow []string
  28. monthsWide []string
  29. daysAbbreviated []string
  30. daysNarrow []string
  31. daysShort []string
  32. daysWide []string
  33. periodsAbbreviated []string
  34. periodsNarrow []string
  35. periodsShort []string
  36. periodsWide []string
  37. erasAbbreviated []string
  38. erasNarrow []string
  39. erasWide []string
  40. timezones map[string]string
  41. }
  42. // New returns a new instance of translator for the 'ro_MD' locale
  43. func New() locales.Translator {
  44. return &ro_MD{
  45. locale: "ro_MD",
  46. pluralsCardinal: []locales.PluralRule{2, 4, 6},
  47. pluralsOrdinal: []locales.PluralRule{2, 6},
  48. pluralsRange: []locales.PluralRule{4, 6},
  49. decimal: ",",
  50. group: ".",
  51. minus: "-",
  52. percent: "%",
  53. perMille: "‰",
  54. timeSeparator: ":",
  55. inifinity: "∞",
  56. 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", "L", "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"},
  57. percentSuffix: " ",
  58. currencyPositiveSuffix: " ",
  59. currencyNegativePrefix: "(",
  60. currencyNegativeSuffix: " )",
  61. monthsAbbreviated: []string{"", "ian.", "feb.", "mar.", "apr.", "mai", "iun.", "iul.", "aug.", "sept.", "oct.", "nov.", "dec."},
  62. monthsNarrow: []string{"", "I", "F", "M", "A", "M", "I", "I", "A", "S", "O", "N", "D"},
  63. monthsWide: []string{"", "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"},
  64. daysAbbreviated: []string{"Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sâm"},
  65. daysNarrow: []string{"D", "L", "Ma", "Mi", "J", "V", "S"},
  66. daysShort: []string{"Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ"},
  67. daysWide: []string{"duminică", "luni", "marți", "miercuri", "joi", "vineri", "sâmbătă"},
  68. periodsAbbreviated: []string{"a.m.", "p.m."},
  69. periodsNarrow: []string{"", ""},
  70. periodsWide: []string{"", ""},
  71. erasAbbreviated: []string{"", ""},
  72. erasNarrow: []string{"", ""},
  73. erasWide: []string{"", ""},
  74. timezones: map[string]string{"HKT": "Ora standard din Hong Kong", "LHDT": "Ora de vară din Lord Howe", "HAST": "Ora standard din Hawaii-Aleutine", "ARST": "Ora de vară a Argentinei", "COST": "Ora de vară a Columbiei", "SAST": "Ora Africii Meridionale", "ACST": "Ora standard a Australiei Centrale", "TMST": "Ora de vară din Turkmenistan", "GMT": "Ora de Greenwhich", "MST": "Ora standard în zona montană nord-americană", "GFT": "Ora din Guyana Franceză", "AKST": "Ora standard din Alaska", "EDT": "Ora de vară orientală nord-americană", "ACWST": "Ora standard a Australiei Central Occidentale", "MESZ": "Ora de vară a Europei Centrale", "TMT": "Ora standard din Turkmenistan", "AST": "Ora standard în zona Atlantic nord-americană", "WIB": "Ora Indoneziei de Vest", "BT": "Ora Bhutanului", "WARST": "Ora de vară a Argentinei Occidentale", "GYT": "Ora din Guyana", "HEEG": "Ora de vară a Groenlandei orientale", "HEPM": "Ora de vară din Saint-Pierre și Miquelon", "COT": "Ora standard a Columbiei", "AWST": "Ora standard a Australiei Occidentale", "HNOG": "Ora standard a Groenlandei occidentale", "HNPM": "Ora standard din Saint-Pierre și Miquelon", "CLT": "Ora standard din Chile", "WIT": "Ora Indoneziei de Est", "HNEG": "Ora standard a Groenlandei orientale", "JST": "Ora standard a Japoniei", "BOT": "Ora Boliviei", "AKDT": "Ora de vară din Alaska", "HEOG": "Ora de vară a Groenlandei occidentale", "CLST": "Ora de vară din Chile", "∅∅∅": "Ora de vară a Amazonului", "WEZ": "Ora standard a Europei de Vest", "WESZ": "Ora de vară a Europei de Vest", "MEZ": "Ora standard a Europei Centrale", "OESZ": "Ora de vară a Europei de Est", "HNPMX": "Ora standard a zonei Pacific mexicane", "WAST": "Ora de vară a Africii Occidentale", "ACDT": "Ora de vară a Australiei Centrale", "EST": "Ora standard orientală nord-americană", "LHST": "Ora standard din Lord Howe", "WART": "Ora standard a Argentinei Occidentale", "CAT": "Ora Africii Centrale", "ADT": "Ora de vară în zona Atlantic nord-americană", "WAT": "Ora standard a Africii Occidentale", "NZDT": "Ora de vară a Noii Zeelande", "UYT": "Ora standard a Uruguayului", "HKST": "Ora de vară din Hong Kong", "HAT": "Ora de vară din Newfoundland", "WITA": "Ora Indoneziei Centrale", "EAT": "Ora Africii Orientale", "CHAST": "Ora standard din Chatham", "HECU": "Ora de vară a Cubei", "AEDT": "Ora de vară a Australiei Orientale", "SGT": "Ora din Singapore", "HNCU": "Ora standard a Cubei", "CST": "Ora standard centrală nord-americană", "CDT": "Ora de vară centrală nord-americană", "MYT": "Ora din Malaysia", "PDT": "Ora de vară în zona Pacific nord-americană", "NZST": "Ora standard a Noii Zeelande", "IST": "Ora Indiei", "VET": "Ora Venezuelei", "OEZ": "Ora standard a Europei de Est", "ART": "Ora standard a Argentinei", "ChST": "Ora din Chamorro", "PST": "Ora standard în zona Pacific nord-americană", "HNNOMX": "Ora standard a Mexicului de nord-vest", "SRT": "Ora Surinamului", "HNT": "Ora standard din Newfoundland", "HADT": "Ora de vară din Hawaii-Aleutine", "UYST": "Ora de vară a Uruguayului", "AWDT": "Ora de vară a Australiei Occidentale", "ECT": "Ora Ecuadorului", "ACWDT": "Ora de vară a Australiei Central Occidentale", "JDT": "Ora de vară a Japoniei", "HENOMX": "Ora de vară a Mexicului de nord-vest", "CHADT": "Ora de vară din Chatham", "HEPMX": "Ora de vară a zonei Pacific mexicane", "AEST": "Ora standard a Australiei Orientale", "MDT": "Ora de vară în zona montană nord-americană"},
  75. }
  76. }
  77. // Locale returns the current translators string locale
  78. func (ro *ro_MD) Locale() string {
  79. return ro.locale
  80. }
  81. // PluralsCardinal returns the list of cardinal plural rules associated with 'ro_MD'
  82. func (ro *ro_MD) PluralsCardinal() []locales.PluralRule {
  83. return ro.pluralsCardinal
  84. }
  85. // PluralsOrdinal returns the list of ordinal plural rules associated with 'ro_MD'
  86. func (ro *ro_MD) PluralsOrdinal() []locales.PluralRule {
  87. return ro.pluralsOrdinal
  88. }
  89. // PluralsRange returns the list of range plural rules associated with 'ro_MD'
  90. func (ro *ro_MD) PluralsRange() []locales.PluralRule {
  91. return ro.pluralsRange
  92. }
  93. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ro_MD'
  94. func (ro *ro_MD) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  95. n := math.Abs(num)
  96. i := int64(n)
  97. nMod100 := math.Mod(n, 100)
  98. if i == 1 && v == 0 {
  99. return locales.PluralRuleOne
  100. } else if (v != 0) || (n == 0) || (n != 1 && nMod100 >= 1 && nMod100 <= 19) {
  101. return locales.PluralRuleFew
  102. }
  103. return locales.PluralRuleOther
  104. }
  105. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ro_MD'
  106. func (ro *ro_MD) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  107. n := math.Abs(num)
  108. if n == 1 {
  109. return locales.PluralRuleOne
  110. }
  111. return locales.PluralRuleOther
  112. }
  113. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ro_MD'
  114. func (ro *ro_MD) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  115. start := ro.CardinalPluralRule(num1, v1)
  116. end := ro.CardinalPluralRule(num2, v2)
  117. 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.PluralRuleFew
  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.PluralRuleFew {
  128. return locales.PluralRuleFew
  129. }
  130. return locales.PluralRuleOther
  131. }
  132. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  133. func (ro *ro_MD) MonthAbbreviated(month time.Month) string {
  134. return ro.monthsAbbreviated[month]
  135. }
  136. // MonthsAbbreviated returns the locales abbreviated months
  137. func (ro *ro_MD) MonthsAbbreviated() []string {
  138. return ro.monthsAbbreviated[1:]
  139. }
  140. // MonthNarrow returns the locales narrow month given the 'month' provided
  141. func (ro *ro_MD) MonthNarrow(month time.Month) string {
  142. return ro.monthsNarrow[month]
  143. }
  144. // MonthsNarrow returns the locales narrow months
  145. func (ro *ro_MD) MonthsNarrow() []string {
  146. return ro.monthsNarrow[1:]
  147. }
  148. // MonthWide returns the locales wide month given the 'month' provided
  149. func (ro *ro_MD) MonthWide(month time.Month) string {
  150. return ro.monthsWide[month]
  151. }
  152. // MonthsWide returns the locales wide months
  153. func (ro *ro_MD) MonthsWide() []string {
  154. return ro.monthsWide[1:]
  155. }
  156. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  157. func (ro *ro_MD) WeekdayAbbreviated(weekday time.Weekday) string {
  158. return ro.daysAbbreviated[weekday]
  159. }
  160. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  161. func (ro *ro_MD) WeekdaysAbbreviated() []string {
  162. return ro.daysAbbreviated
  163. }
  164. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  165. func (ro *ro_MD) WeekdayNarrow(weekday time.Weekday) string {
  166. return ro.daysNarrow[weekday]
  167. }
  168. // WeekdaysNarrow returns the locales narrow weekdays
  169. func (ro *ro_MD) WeekdaysNarrow() []string {
  170. return ro.daysNarrow
  171. }
  172. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  173. func (ro *ro_MD) WeekdayShort(weekday time.Weekday) string {
  174. return ro.daysShort[weekday]
  175. }
  176. // WeekdaysShort returns the locales short weekdays
  177. func (ro *ro_MD) WeekdaysShort() []string {
  178. return ro.daysShort
  179. }
  180. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  181. func (ro *ro_MD) WeekdayWide(weekday time.Weekday) string {
  182. return ro.daysWide[weekday]
  183. }
  184. // WeekdaysWide returns the locales wide weekdays
  185. func (ro *ro_MD) WeekdaysWide() []string {
  186. return ro.daysWide
  187. }
  188. // Decimal returns the decimal point of number
  189. func (ro *ro_MD) Decimal() string {
  190. return ro.decimal
  191. }
  192. // Group returns the group of number
  193. func (ro *ro_MD) Group() string {
  194. return ro.group
  195. }
  196. // Group returns the minus sign of number
  197. func (ro *ro_MD) Minus() string {
  198. return ro.minus
  199. }
  200. // FmtNumber returns 'num' with digits/precision of 'v' for 'ro_MD' and handles both Whole and Real numbers based on 'v'
  201. func (ro *ro_MD) FmtNumber(num float64, v uint64) string {
  202. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  203. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  204. count := 0
  205. inWhole := v == 0
  206. b := make([]byte, 0, l)
  207. for i := len(s) - 1; i >= 0; i-- {
  208. if s[i] == '.' {
  209. b = append(b, ro.decimal[0])
  210. inWhole = true
  211. continue
  212. }
  213. if inWhole {
  214. if count == 3 {
  215. b = append(b, ro.group[0])
  216. count = 1
  217. } else {
  218. count++
  219. }
  220. }
  221. b = append(b, s[i])
  222. }
  223. if num < 0 {
  224. b = append(b, ro.minus[0])
  225. }
  226. // reverse
  227. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  228. b[i], b[j] = b[j], b[i]
  229. }
  230. return string(b)
  231. }
  232. // FmtPercent returns 'num' with digits/precision of 'v' for 'ro_MD' and handles both Whole and Real numbers based on 'v'
  233. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  234. func (ro *ro_MD) FmtPercent(num float64, v uint64) string {
  235. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  236. l := len(s) + 5
  237. b := make([]byte, 0, l)
  238. for i := len(s) - 1; i >= 0; i-- {
  239. if s[i] == '.' {
  240. b = append(b, ro.decimal[0])
  241. continue
  242. }
  243. b = append(b, s[i])
  244. }
  245. if num < 0 {
  246. b = append(b, ro.minus[0])
  247. }
  248. // reverse
  249. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  250. b[i], b[j] = b[j], b[i]
  251. }
  252. b = append(b, ro.percentSuffix...)
  253. b = append(b, ro.percent...)
  254. return string(b)
  255. }
  256. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ro_MD'
  257. func (ro *ro_MD) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  258. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  259. symbol := ro.currencies[currency]
  260. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  261. count := 0
  262. inWhole := v == 0
  263. b := make([]byte, 0, l)
  264. for i := len(s) - 1; i >= 0; i-- {
  265. if s[i] == '.' {
  266. b = append(b, ro.decimal[0])
  267. inWhole = true
  268. continue
  269. }
  270. if inWhole {
  271. if count == 3 {
  272. b = append(b, ro.group[0])
  273. count = 1
  274. } else {
  275. count++
  276. }
  277. }
  278. b = append(b, s[i])
  279. }
  280. if num < 0 {
  281. b = append(b, ro.minus[0])
  282. }
  283. // reverse
  284. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  285. b[i], b[j] = b[j], b[i]
  286. }
  287. if int(v) < 2 {
  288. if v == 0 {
  289. b = append(b, ro.decimal...)
  290. }
  291. for i := 0; i < 2-int(v); i++ {
  292. b = append(b, '0')
  293. }
  294. }
  295. b = append(b, ro.currencyPositiveSuffix...)
  296. b = append(b, symbol...)
  297. return string(b)
  298. }
  299. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ro_MD'
  300. // in accounting notation.
  301. func (ro *ro_MD) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  302. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  303. symbol := ro.currencies[currency]
  304. l := len(s) + len(symbol) + 6 + 1*len(s[:len(s)-int(v)-1])/3
  305. count := 0
  306. inWhole := v == 0
  307. b := make([]byte, 0, l)
  308. for i := len(s) - 1; i >= 0; i-- {
  309. if s[i] == '.' {
  310. b = append(b, ro.decimal[0])
  311. inWhole = true
  312. continue
  313. }
  314. if inWhole {
  315. if count == 3 {
  316. b = append(b, ro.group[0])
  317. count = 1
  318. } else {
  319. count++
  320. }
  321. }
  322. b = append(b, s[i])
  323. }
  324. if num < 0 {
  325. b = append(b, ro.currencyNegativePrefix[0])
  326. }
  327. // reverse
  328. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  329. b[i], b[j] = b[j], b[i]
  330. }
  331. if int(v) < 2 {
  332. if v == 0 {
  333. b = append(b, ro.decimal...)
  334. }
  335. for i := 0; i < 2-int(v); i++ {
  336. b = append(b, '0')
  337. }
  338. }
  339. if num < 0 {
  340. b = append(b, ro.currencyNegativeSuffix...)
  341. b = append(b, symbol...)
  342. } else {
  343. b = append(b, ro.currencyPositiveSuffix...)
  344. b = append(b, symbol...)
  345. }
  346. return string(b)
  347. }
  348. // FmtDateShort returns the short date representation of 't' for 'ro_MD'
  349. func (ro *ro_MD) FmtDateShort(t time.Time) string {
  350. b := make([]byte, 0, 32)
  351. if t.Day() < 10 {
  352. b = append(b, '0')
  353. }
  354. b = strconv.AppendInt(b, int64(t.Day()), 10)
  355. b = append(b, []byte{0x2e}...)
  356. if t.Month() < 10 {
  357. b = append(b, '0')
  358. }
  359. b = strconv.AppendInt(b, int64(t.Month()), 10)
  360. b = append(b, []byte{0x2e}...)
  361. if t.Year() > 0 {
  362. b = strconv.AppendInt(b, int64(t.Year()), 10)
  363. } else {
  364. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  365. }
  366. return string(b)
  367. }
  368. // FmtDateMedium returns the medium date representation of 't' for 'ro_MD'
  369. func (ro *ro_MD) FmtDateMedium(t time.Time) string {
  370. b := make([]byte, 0, 32)
  371. b = strconv.AppendInt(b, int64(t.Day()), 10)
  372. b = append(b, []byte{0x20}...)
  373. b = append(b, ro.monthsAbbreviated[t.Month()]...)
  374. b = append(b, []byte{0x20}...)
  375. if t.Year() > 0 {
  376. b = strconv.AppendInt(b, int64(t.Year()), 10)
  377. } else {
  378. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  379. }
  380. return string(b)
  381. }
  382. // FmtDateLong returns the long date representation of 't' for 'ro_MD'
  383. func (ro *ro_MD) FmtDateLong(t time.Time) string {
  384. b := make([]byte, 0, 32)
  385. b = strconv.AppendInt(b, int64(t.Day()), 10)
  386. b = append(b, []byte{0x20}...)
  387. b = append(b, ro.monthsWide[t.Month()]...)
  388. b = append(b, []byte{0x20}...)
  389. if t.Year() > 0 {
  390. b = strconv.AppendInt(b, int64(t.Year()), 10)
  391. } else {
  392. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  393. }
  394. return string(b)
  395. }
  396. // FmtDateFull returns the full date representation of 't' for 'ro_MD'
  397. func (ro *ro_MD) FmtDateFull(t time.Time) string {
  398. b := make([]byte, 0, 32)
  399. b = append(b, ro.daysWide[t.Weekday()]...)
  400. b = append(b, []byte{0x2c, 0x20}...)
  401. b = strconv.AppendInt(b, int64(t.Day()), 10)
  402. b = append(b, []byte{0x20}...)
  403. b = append(b, ro.monthsWide[t.Month()]...)
  404. b = append(b, []byte{0x20}...)
  405. if t.Year() > 0 {
  406. b = strconv.AppendInt(b, int64(t.Year()), 10)
  407. } else {
  408. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  409. }
  410. return string(b)
  411. }
  412. // FmtTimeShort returns the short time representation of 't' for 'ro_MD'
  413. func (ro *ro_MD) FmtTimeShort(t time.Time) string {
  414. b := make([]byte, 0, 32)
  415. if t.Hour() < 10 {
  416. b = append(b, '0')
  417. }
  418. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  419. b = append(b, ro.timeSeparator...)
  420. if t.Minute() < 10 {
  421. b = append(b, '0')
  422. }
  423. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  424. return string(b)
  425. }
  426. // FmtTimeMedium returns the medium time representation of 't' for 'ro_MD'
  427. func (ro *ro_MD) FmtTimeMedium(t time.Time) string {
  428. b := make([]byte, 0, 32)
  429. if t.Hour() < 10 {
  430. b = append(b, '0')
  431. }
  432. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  433. b = append(b, ro.timeSeparator...)
  434. if t.Minute() < 10 {
  435. b = append(b, '0')
  436. }
  437. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  438. b = append(b, ro.timeSeparator...)
  439. if t.Second() < 10 {
  440. b = append(b, '0')
  441. }
  442. b = strconv.AppendInt(b, int64(t.Second()), 10)
  443. return string(b)
  444. }
  445. // FmtTimeLong returns the long time representation of 't' for 'ro_MD'
  446. func (ro *ro_MD) FmtTimeLong(t time.Time) string {
  447. b := make([]byte, 0, 32)
  448. if t.Hour() < 10 {
  449. b = append(b, '0')
  450. }
  451. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  452. b = append(b, ro.timeSeparator...)
  453. if t.Minute() < 10 {
  454. b = append(b, '0')
  455. }
  456. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  457. b = append(b, ro.timeSeparator...)
  458. if t.Second() < 10 {
  459. b = append(b, '0')
  460. }
  461. b = strconv.AppendInt(b, int64(t.Second()), 10)
  462. b = append(b, []byte{0x20}...)
  463. tz, _ := t.Zone()
  464. b = append(b, tz...)
  465. return string(b)
  466. }
  467. // FmtTimeFull returns the full time representation of 't' for 'ro_MD'
  468. func (ro *ro_MD) FmtTimeFull(t time.Time) string {
  469. b := make([]byte, 0, 32)
  470. if t.Hour() < 10 {
  471. b = append(b, '0')
  472. }
  473. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  474. b = append(b, ro.timeSeparator...)
  475. if t.Minute() < 10 {
  476. b = append(b, '0')
  477. }
  478. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  479. b = append(b, ro.timeSeparator...)
  480. if t.Second() < 10 {
  481. b = append(b, '0')
  482. }
  483. b = strconv.AppendInt(b, int64(t.Second()), 10)
  484. b = append(b, []byte{0x20}...)
  485. tz, _ := t.Zone()
  486. if btz, ok := ro.timezones[tz]; ok {
  487. b = append(b, btz...)
  488. } else {
  489. b = append(b, tz...)
  490. }
  491. return string(b)
  492. }