lt_LT.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. package lt_LT
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type lt_LT 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. 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 'lt_LT' locale
  42. func New() locales.Translator {
  43. return &lt_LT{
  44. locale: "lt_LT",
  45. pluralsCardinal: []locales.PluralRule{2, 4, 5, 6},
  46. pluralsOrdinal: []locales.PluralRule{6},
  47. pluralsRange: []locales.PluralRule{2, 4, 5, 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. percentSuffix: " ",
  57. currencyPositiveSuffix: " ",
  58. currencyNegativeSuffix: " ",
  59. monthsAbbreviated: []string{"", "saus.", "vas.", "kov.", "bal.", "geg.", "birž.", "liep.", "rugp.", "rugs.", "spal.", "lapkr.", "gruod."},
  60. monthsNarrow: []string{"", "S", "V", "K", "B", "G", "B", "L", "R", "R", "S", "L", "G"},
  61. monthsWide: []string{"", "sausio", "vasario", "kovo", "balandžio", "gegužės", "birželio", "liepos", "rugpjūčio", "rugsėjo", "spalio", "lapkričio", "gruodžio"},
  62. daysAbbreviated: []string{"sk", "pr", "an", "tr", "kt", "pn", "št"},
  63. daysNarrow: []string{"S", "P", "A", "T", "K", "P", "Š"},
  64. daysShort: []string{"Sk", "Pr", "An", "Tr", "Kt", "Pn", "Št"},
  65. daysWide: []string{"sekmadienis", "pirmadienis", "antradienis", "trečiadienis", "ketvirtadienis", "penktadienis", "šeštadienis"},
  66. periodsAbbreviated: []string{"priešpiet", "popiet"},
  67. periodsNarrow: []string{"pr. p.", "pop."},
  68. periodsWide: []string{"priešpiet", "popiet"},
  69. erasAbbreviated: []string{"pr. Kr.", "po Kr."},
  70. erasNarrow: []string{"pr. Kr.", "po Kr."},
  71. erasWide: []string{"prieš Kristų", "po Kristaus"},
  72. timezones: map[string]string{"WIB": "Vakarų Indonezijos laikas", "NZST": "Naujosios Zelandijos žiemos laikas", "HNOG": "Grenlandijos vakarų žiemos laikas", "HEPM": "Sen Pjero ir Mikelono vasaros laikas", "HAST": "Havajų–Aleutų žiemos laikas", "GMT": "Grinvičo laikas", "UYST": "Urugvajaus vasaros laikas", "AKDT": "Aliaskos vasaros laikas", "ACWDT": "Centrinės vakarų Australijos vasaros laikas", "MEZ": "Vidurio Europos žiemos laikas", "CAT": "Centrinės Afrikos laikas", "HECU": "Kubos vasaros laikas", "HNPMX": "Meksikos Ramiojo vandenyno žiemos laikas", "AEDT": "Rytų Australijos vasaros laikas", "ECT": "Ekvadoro laikas", "GYT": "Gajanos laikas", "AEST": "Rytų Australijos žiemos laikas", "SAST": "Pietų Afrikos laikas", "WAT": "Vakarų Afrikos žiemos laikas", "MYT": "Malaizijos laikas", "JDT": "Japonijos vasaros laikas", "EST": "Šiaurės Amerikos rytų žiemos laikas", "WART": "Vakarų Argentinos žiemos laikas", "ADT": "Atlanto vasaros laikas", "ACST": "Centrinės Australijos žiemos laikas", "HAT": "Niufaundlendo vasaros laikas", "WITA": "Centrinės Indonezijos laikas", "TMST": "Turkmėnistano vasaros laikas", "OEZ": "Rytų Europos žiemos laikas", "CHAST": "Čatamo žiemos laikas", "HNCU": "Kubos žiemos laikas", "MDT": "Šiaurės Amerikos kalnų vasaros laikas", "WEZ": "Vakarų Europos žiemos laikas", "∅∅∅": "Ako vasaros laikas", "WARST": "Vakarų Argentinos vasaros laikas", "HNT": "Niufaundlendo žiemos laikas", "WIT": "Rytų Indonezijos laikas", "CHADT": "Čatamo vasaros laikas", "MST": "Šiaurės Amerikos kalnų žiemos laikas", "WESZ": "Vakarų Europos vasaros laikas", "HENOMX": "Šiaurės Vakarų Meksikos vasaros laikas", "CLT": "Čilės žiemos laikas", "HEPMX": "Meksikos Ramiojo vandenyno vasaros laikas", "ACDT": "Centrinės Australijos vasaros laikas", "HEOG": "Grenlandijos vakarų vasaros laikas", "HNPM": "Sen Pjero ir Mikelono žiemos laikas", "BOT": "Bolivijos laikas", "EDT": "Šiaurės Amerikos rytų vasaros laikas", "IST": "Indijos laikas", "CLST": "Čilės vasaros laikas", "JST": "Japonijos žiemos laikas", "SRT": "Surinamo laikas", "WAST": "Vakarų Afrikos vasaros laikas", "HNEG": "Grenlandijos rytų žiemos laikas", "MESZ": "Vidurio Europos vasaros laikas", "HNNOMX": "Šiaurės Vakarų Meksikos žiemos laikas", "TMT": "Turkmėnistano žiemos laikas", "ARST": "Argentinos vasaros laikas", "UYT": "Urugvajaus žiemos laikas", "HKST": "Honkongo vasaros laikas", "CST": "Šiaurės Amerikos centro žiemos laikas", "AWST": "Vakarų Australijos žiemos laikas", "PDT": "Šiaurės Amerikos Ramiojo vandenyno vasaros laikas", "BT": "Butano laikas", "NZDT": "Naujosios Zelandijos vasaros laikas", "AKST": "Aliaskos žiemos laikas", "ACWST": "Centrinės vakarų Australijos žiemos laikas", "LHST": "Lordo Hau žiemos laikas", "COST": "Kolumbijos vasaros laikas", "ChST": "Čamoro laikas", "SGT": "Singapūro laikas", "HEEG": "Grenlandijos rytų vasaros laikas", "HKT": "Honkongo žiemos laikas", "LHDT": "Lordo Hau vasaros laikas", "VET": "Venesuelos laikas", "OESZ": "Rytų Europos vasaros laikas", "ART": "Argentinos žiemos laikas", "AST": "Atlanto žiemos laikas", "GFT": "Prancūzijos Gvianos laikas", "EAT": "Rytų Afrikos laikas", "HADT": "Havajų–Aleutų vasaros laikas", "COT": "Kolumbijos žiemos laikas", "CDT": "Šiaurės Amerikos centro vasaros laikas", "PST": "Šiaurės Amerikos Ramiojo vandenyno žiemos laikas", "AWDT": "Vakarų Australijos vasaros laikas"},
  73. }
  74. }
  75. // Locale returns the current translators string locale
  76. func (lt *lt_LT) Locale() string {
  77. return lt.locale
  78. }
  79. // PluralsCardinal returns the list of cardinal plural rules associated with 'lt_LT'
  80. func (lt *lt_LT) PluralsCardinal() []locales.PluralRule {
  81. return lt.pluralsCardinal
  82. }
  83. // PluralsOrdinal returns the list of ordinal plural rules associated with 'lt_LT'
  84. func (lt *lt_LT) PluralsOrdinal() []locales.PluralRule {
  85. return lt.pluralsOrdinal
  86. }
  87. // PluralsRange returns the list of range plural rules associated with 'lt_LT'
  88. func (lt *lt_LT) PluralsRange() []locales.PluralRule {
  89. return lt.pluralsRange
  90. }
  91. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lt_LT'
  92. func (lt *lt_LT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  93. n := math.Abs(num)
  94. f := locales.F(n, v)
  95. nMod10 := math.Mod(n, 10)
  96. nMod100 := math.Mod(n, 100)
  97. if nMod10 == 1 && (nMod100 < 11 || nMod100 > 19) {
  98. return locales.PluralRuleOne
  99. } else if nMod10 >= 2 && nMod10 <= 9 && (nMod100 < 11 || nMod100 > 19) {
  100. return locales.PluralRuleFew
  101. } else if f != 0 {
  102. return locales.PluralRuleMany
  103. }
  104. return locales.PluralRuleOther
  105. }
  106. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lt_LT'
  107. func (lt *lt_LT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  108. return locales.PluralRuleOther
  109. }
  110. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lt_LT'
  111. func (lt *lt_LT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  112. start := lt.CardinalPluralRule(num1, v1)
  113. end := lt.CardinalPluralRule(num2, v2)
  114. if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
  115. return locales.PluralRuleOne
  116. } else if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
  117. return locales.PluralRuleFew
  118. } else if start == locales.PluralRuleOne && end == locales.PluralRuleMany {
  119. return locales.PluralRuleMany
  120. } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
  121. return locales.PluralRuleOther
  122. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOne {
  123. return locales.PluralRuleOne
  124. } else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
  125. return locales.PluralRuleFew
  126. } else if start == locales.PluralRuleFew && end == locales.PluralRuleMany {
  127. return locales.PluralRuleMany
  128. } else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
  129. return locales.PluralRuleOther
  130. } else if start == locales.PluralRuleMany && end == locales.PluralRuleOne {
  131. return locales.PluralRuleOne
  132. } else if start == locales.PluralRuleMany && end == locales.PluralRuleFew {
  133. return locales.PluralRuleFew
  134. } else if start == locales.PluralRuleMany && end == locales.PluralRuleMany {
  135. return locales.PluralRuleMany
  136. } else if start == locales.PluralRuleMany && end == locales.PluralRuleOther {
  137. return locales.PluralRuleOther
  138. } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
  139. return locales.PluralRuleOne
  140. } else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
  141. return locales.PluralRuleFew
  142. } else if start == locales.PluralRuleOther && end == locales.PluralRuleMany {
  143. return locales.PluralRuleMany
  144. }
  145. return locales.PluralRuleOther
  146. }
  147. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  148. func (lt *lt_LT) MonthAbbreviated(month time.Month) string {
  149. return lt.monthsAbbreviated[month]
  150. }
  151. // MonthsAbbreviated returns the locales abbreviated months
  152. func (lt *lt_LT) MonthsAbbreviated() []string {
  153. return lt.monthsAbbreviated[1:]
  154. }
  155. // MonthNarrow returns the locales narrow month given the 'month' provided
  156. func (lt *lt_LT) MonthNarrow(month time.Month) string {
  157. return lt.monthsNarrow[month]
  158. }
  159. // MonthsNarrow returns the locales narrow months
  160. func (lt *lt_LT) MonthsNarrow() []string {
  161. return lt.monthsNarrow[1:]
  162. }
  163. // MonthWide returns the locales wide month given the 'month' provided
  164. func (lt *lt_LT) MonthWide(month time.Month) string {
  165. return lt.monthsWide[month]
  166. }
  167. // MonthsWide returns the locales wide months
  168. func (lt *lt_LT) MonthsWide() []string {
  169. return lt.monthsWide[1:]
  170. }
  171. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  172. func (lt *lt_LT) WeekdayAbbreviated(weekday time.Weekday) string {
  173. return lt.daysAbbreviated[weekday]
  174. }
  175. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  176. func (lt *lt_LT) WeekdaysAbbreviated() []string {
  177. return lt.daysAbbreviated
  178. }
  179. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  180. func (lt *lt_LT) WeekdayNarrow(weekday time.Weekday) string {
  181. return lt.daysNarrow[weekday]
  182. }
  183. // WeekdaysNarrow returns the locales narrow weekdays
  184. func (lt *lt_LT) WeekdaysNarrow() []string {
  185. return lt.daysNarrow
  186. }
  187. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  188. func (lt *lt_LT) WeekdayShort(weekday time.Weekday) string {
  189. return lt.daysShort[weekday]
  190. }
  191. // WeekdaysShort returns the locales short weekdays
  192. func (lt *lt_LT) WeekdaysShort() []string {
  193. return lt.daysShort
  194. }
  195. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  196. func (lt *lt_LT) WeekdayWide(weekday time.Weekday) string {
  197. return lt.daysWide[weekday]
  198. }
  199. // WeekdaysWide returns the locales wide weekdays
  200. func (lt *lt_LT) WeekdaysWide() []string {
  201. return lt.daysWide
  202. }
  203. // Decimal returns the decimal point of number
  204. func (lt *lt_LT) Decimal() string {
  205. return lt.decimal
  206. }
  207. // Group returns the group of number
  208. func (lt *lt_LT) Group() string {
  209. return lt.group
  210. }
  211. // Group returns the minus sign of number
  212. func (lt *lt_LT) Minus() string {
  213. return lt.minus
  214. }
  215. // FmtNumber returns 'num' with digits/precision of 'v' for 'lt_LT' and handles both Whole and Real numbers based on 'v'
  216. func (lt *lt_LT) FmtNumber(num float64, v uint64) string {
  217. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  218. l := len(s) + 4 + 2*len(s[:len(s)-int(v)-1])/3
  219. count := 0
  220. inWhole := v == 0
  221. b := make([]byte, 0, l)
  222. for i := len(s) - 1; i >= 0; i-- {
  223. if s[i] == '.' {
  224. b = append(b, lt.decimal[0])
  225. inWhole = true
  226. continue
  227. }
  228. if inWhole {
  229. if count == 3 {
  230. for j := len(lt.group) - 1; j >= 0; j-- {
  231. b = append(b, lt.group[j])
  232. }
  233. count = 1
  234. } else {
  235. count++
  236. }
  237. }
  238. b = append(b, s[i])
  239. }
  240. if num < 0 {
  241. for j := len(lt.minus) - 1; j >= 0; j-- {
  242. b = append(b, lt.minus[j])
  243. }
  244. }
  245. // reverse
  246. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  247. b[i], b[j] = b[j], b[i]
  248. }
  249. return string(b)
  250. }
  251. // FmtPercent returns 'num' with digits/precision of 'v' for 'lt_LT' and handles both Whole and Real numbers based on 'v'
  252. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  253. func (lt *lt_LT) FmtPercent(num float64, v uint64) string {
  254. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  255. l := len(s) + 7
  256. b := make([]byte, 0, l)
  257. for i := len(s) - 1; i >= 0; i-- {
  258. if s[i] == '.' {
  259. b = append(b, lt.decimal[0])
  260. continue
  261. }
  262. b = append(b, s[i])
  263. }
  264. if num < 0 {
  265. for j := len(lt.minus) - 1; j >= 0; j-- {
  266. b = append(b, lt.minus[j])
  267. }
  268. }
  269. // reverse
  270. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  271. b[i], b[j] = b[j], b[i]
  272. }
  273. b = append(b, lt.percentSuffix...)
  274. b = append(b, lt.percent...)
  275. return string(b)
  276. }
  277. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lt_LT'
  278. func (lt *lt_LT) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  279. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  280. symbol := lt.currencies[currency]
  281. l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
  282. count := 0
  283. inWhole := v == 0
  284. b := make([]byte, 0, l)
  285. for i := len(s) - 1; i >= 0; i-- {
  286. if s[i] == '.' {
  287. b = append(b, lt.decimal[0])
  288. inWhole = true
  289. continue
  290. }
  291. if inWhole {
  292. if count == 3 {
  293. for j := len(lt.group) - 1; j >= 0; j-- {
  294. b = append(b, lt.group[j])
  295. }
  296. count = 1
  297. } else {
  298. count++
  299. }
  300. }
  301. b = append(b, s[i])
  302. }
  303. if num < 0 {
  304. for j := len(lt.minus) - 1; j >= 0; j-- {
  305. b = append(b, lt.minus[j])
  306. }
  307. }
  308. // reverse
  309. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  310. b[i], b[j] = b[j], b[i]
  311. }
  312. if int(v) < 2 {
  313. if v == 0 {
  314. b = append(b, lt.decimal...)
  315. }
  316. for i := 0; i < 2-int(v); i++ {
  317. b = append(b, '0')
  318. }
  319. }
  320. b = append(b, lt.currencyPositiveSuffix...)
  321. b = append(b, symbol...)
  322. return string(b)
  323. }
  324. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lt_LT'
  325. // in accounting notation.
  326. func (lt *lt_LT) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  327. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  328. symbol := lt.currencies[currency]
  329. l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
  330. count := 0
  331. inWhole := v == 0
  332. b := make([]byte, 0, l)
  333. for i := len(s) - 1; i >= 0; i-- {
  334. if s[i] == '.' {
  335. b = append(b, lt.decimal[0])
  336. inWhole = true
  337. continue
  338. }
  339. if inWhole {
  340. if count == 3 {
  341. for j := len(lt.group) - 1; j >= 0; j-- {
  342. b = append(b, lt.group[j])
  343. }
  344. count = 1
  345. } else {
  346. count++
  347. }
  348. }
  349. b = append(b, s[i])
  350. }
  351. if num < 0 {
  352. for j := len(lt.minus) - 1; j >= 0; j-- {
  353. b = append(b, lt.minus[j])
  354. }
  355. }
  356. // reverse
  357. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  358. b[i], b[j] = b[j], b[i]
  359. }
  360. if int(v) < 2 {
  361. if v == 0 {
  362. b = append(b, lt.decimal...)
  363. }
  364. for i := 0; i < 2-int(v); i++ {
  365. b = append(b, '0')
  366. }
  367. }
  368. if num < 0 {
  369. b = append(b, lt.currencyNegativeSuffix...)
  370. b = append(b, symbol...)
  371. } else {
  372. b = append(b, lt.currencyPositiveSuffix...)
  373. b = append(b, symbol...)
  374. }
  375. return string(b)
  376. }
  377. // FmtDateShort returns the short date representation of 't' for 'lt_LT'
  378. func (lt *lt_LT) FmtDateShort(t time.Time) string {
  379. b := make([]byte, 0, 32)
  380. if t.Year() > 0 {
  381. b = strconv.AppendInt(b, int64(t.Year()), 10)
  382. } else {
  383. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  384. }
  385. b = append(b, []byte{0x2d}...)
  386. if t.Month() < 10 {
  387. b = append(b, '0')
  388. }
  389. b = strconv.AppendInt(b, int64(t.Month()), 10)
  390. b = append(b, []byte{0x2d}...)
  391. if t.Day() < 10 {
  392. b = append(b, '0')
  393. }
  394. b = strconv.AppendInt(b, int64(t.Day()), 10)
  395. return string(b)
  396. }
  397. // FmtDateMedium returns the medium date representation of 't' for 'lt_LT'
  398. func (lt *lt_LT) FmtDateMedium(t time.Time) string {
  399. b := make([]byte, 0, 32)
  400. if t.Year() > 0 {
  401. b = strconv.AppendInt(b, int64(t.Year()), 10)
  402. } else {
  403. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  404. }
  405. b = append(b, []byte{0x2d}...)
  406. if t.Month() < 10 {
  407. b = append(b, '0')
  408. }
  409. b = strconv.AppendInt(b, int64(t.Month()), 10)
  410. b = append(b, []byte{0x2d}...)
  411. if t.Day() < 10 {
  412. b = append(b, '0')
  413. }
  414. b = strconv.AppendInt(b, int64(t.Day()), 10)
  415. return string(b)
  416. }
  417. // FmtDateLong returns the long date representation of 't' for 'lt_LT'
  418. func (lt *lt_LT) FmtDateLong(t time.Time) string {
  419. b := make([]byte, 0, 32)
  420. if t.Year() > 0 {
  421. b = strconv.AppendInt(b, int64(t.Year()), 10)
  422. } else {
  423. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  424. }
  425. b = append(b, []byte{0x20, 0x6d}...)
  426. b = append(b, []byte{0x2e, 0x20}...)
  427. b = append(b, lt.monthsWide[t.Month()]...)
  428. b = append(b, []byte{0x20}...)
  429. b = strconv.AppendInt(b, int64(t.Day()), 10)
  430. b = append(b, []byte{0x20, 0x64}...)
  431. b = append(b, []byte{0x2e}...)
  432. return string(b)
  433. }
  434. // FmtDateFull returns the full date representation of 't' for 'lt_LT'
  435. func (lt *lt_LT) FmtDateFull(t time.Time) string {
  436. b := make([]byte, 0, 32)
  437. if t.Year() > 0 {
  438. b = strconv.AppendInt(b, int64(t.Year()), 10)
  439. } else {
  440. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  441. }
  442. b = append(b, []byte{0x20, 0x6d}...)
  443. b = append(b, []byte{0x2e, 0x20}...)
  444. b = append(b, lt.monthsWide[t.Month()]...)
  445. b = append(b, []byte{0x20}...)
  446. b = strconv.AppendInt(b, int64(t.Day()), 10)
  447. b = append(b, []byte{0x20, 0x64}...)
  448. b = append(b, []byte{0x2e, 0x2c, 0x20}...)
  449. b = append(b, lt.daysWide[t.Weekday()]...)
  450. return string(b)
  451. }
  452. // FmtTimeShort returns the short time representation of 't' for 'lt_LT'
  453. func (lt *lt_LT) FmtTimeShort(t time.Time) string {
  454. b := make([]byte, 0, 32)
  455. if t.Hour() < 10 {
  456. b = append(b, '0')
  457. }
  458. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  459. b = append(b, lt.timeSeparator...)
  460. if t.Minute() < 10 {
  461. b = append(b, '0')
  462. }
  463. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  464. return string(b)
  465. }
  466. // FmtTimeMedium returns the medium time representation of 't' for 'lt_LT'
  467. func (lt *lt_LT) FmtTimeMedium(t time.Time) string {
  468. b := make([]byte, 0, 32)
  469. if t.Hour() < 10 {
  470. b = append(b, '0')
  471. }
  472. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  473. b = append(b, lt.timeSeparator...)
  474. if t.Minute() < 10 {
  475. b = append(b, '0')
  476. }
  477. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  478. b = append(b, lt.timeSeparator...)
  479. if t.Second() < 10 {
  480. b = append(b, '0')
  481. }
  482. b = strconv.AppendInt(b, int64(t.Second()), 10)
  483. return string(b)
  484. }
  485. // FmtTimeLong returns the long time representation of 't' for 'lt_LT'
  486. func (lt *lt_LT) FmtTimeLong(t time.Time) string {
  487. b := make([]byte, 0, 32)
  488. if t.Hour() < 10 {
  489. b = append(b, '0')
  490. }
  491. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  492. b = append(b, lt.timeSeparator...)
  493. if t.Minute() < 10 {
  494. b = append(b, '0')
  495. }
  496. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  497. b = append(b, lt.timeSeparator...)
  498. if t.Second() < 10 {
  499. b = append(b, '0')
  500. }
  501. b = strconv.AppendInt(b, int64(t.Second()), 10)
  502. b = append(b, []byte{0x20}...)
  503. tz, _ := t.Zone()
  504. b = append(b, tz...)
  505. return string(b)
  506. }
  507. // FmtTimeFull returns the full time representation of 't' for 'lt_LT'
  508. func (lt *lt_LT) FmtTimeFull(t time.Time) string {
  509. b := make([]byte, 0, 32)
  510. if t.Hour() < 10 {
  511. b = append(b, '0')
  512. }
  513. b = strconv.AppendInt(b, int64(t.Hour()), 10)
  514. b = append(b, lt.timeSeparator...)
  515. if t.Minute() < 10 {
  516. b = append(b, '0')
  517. }
  518. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  519. b = append(b, lt.timeSeparator...)
  520. if t.Second() < 10 {
  521. b = append(b, '0')
  522. }
  523. b = strconv.AppendInt(b, int64(t.Second()), 10)
  524. b = append(b, []byte{0x20}...)
  525. tz, _ := t.Zone()
  526. if btz, ok := lt.timezones[tz]; ok {
  527. b = append(b, btz...)
  528. } else {
  529. b = append(b, tz...)
  530. }
  531. return string(b)
  532. }