1package lv_LV 2 3import ( 4 "math" 5 "strconv" 6 "time" 7 8 "github.com/gohugoio/locales" 9 "github.com/gohugoio/locales/currency" 10) 11 12type lv_LV struct { 13 locale string 14 pluralsCardinal []locales.PluralRule 15 pluralsOrdinal []locales.PluralRule 16 pluralsRange []locales.PluralRule 17 decimal string 18 group string 19 minus string 20 percent string 21 perMille string 22 timeSeparator string 23 inifinity string 24 currencies []string // idx = enum of currency code 25 currencyPositiveSuffix string 26 currencyNegativeSuffix string 27 monthsAbbreviated []string 28 monthsNarrow []string 29 monthsWide []string 30 daysAbbreviated []string 31 daysNarrow []string 32 daysShort []string 33 daysWide []string 34 periodsAbbreviated []string 35 periodsNarrow []string 36 periodsShort []string 37 periodsWide []string 38 erasAbbreviated []string 39 erasNarrow []string 40 erasWide []string 41 timezones map[string]string 42} 43 44// New returns a new instance of translator for the 'lv_LV' locale 45func New() locales.Translator { 46 return &lv_LV{ 47 locale: "lv_LV", 48 pluralsCardinal: []locales.PluralRule{1, 2, 6}, 49 pluralsOrdinal: []locales.PluralRule{6}, 50 pluralsRange: []locales.PluralRule{2, 6}, 51 decimal: ",", 52 group: " ", 53 minus: "-", 54 percent: "%", 55 perMille: "‰", 56 timeSeparator: ":", 57 inifinity: "∞", 58 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", "MRU", "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", "UYW", "UZS", "VEB", "VEF", "VES", "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"}, 59 currencyPositiveSuffix: " ", 60 currencyNegativeSuffix: " ", 61 monthsAbbreviated: []string{"", "janv.", "febr.", "marts", "apr.", "maijs", "jūn.", "jūl.", "aug.", "sept.", "okt.", "nov.", "dec."}, 62 monthsNarrow: []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"}, 63 monthsWide: []string{"", "janvāris", "februāris", "marts", "aprīlis", "maijs", "jūnijs", "jūlijs", "augusts", "septembris", "oktobris", "novembris", "decembris"}, 64 daysAbbreviated: []string{"svētd.", "pirmd.", "otrd.", "trešd.", "ceturtd.", "piektd.", "sestd."}, 65 daysNarrow: []string{"S", "P", "O", "T", "C", "P", "S"}, 66 daysShort: []string{"Sv", "Pr", "Ot", "Tr", "Ce", "Pk", "Se"}, 67 daysWide: []string{"svētdiena", "pirmdiena", "otrdiena", "trešdiena", "ceturtdiena", "piektdiena", "sestdiena"}, 68 periodsAbbreviated: []string{"priekšp.", "pēcp."}, 69 periodsNarrow: []string{"priekšp.", "pēcp."}, 70 periodsWide: []string{"priekšpusdienā", "pēcpusdienā"}, 71 erasAbbreviated: []string{"p.m.ē.", "m.ē."}, 72 erasNarrow: []string{"p.m.ē.", "m.ē."}, 73 erasWide: []string{"pirms mūsu ēras", "mūsu ērā"}, 74 timezones: map[string]string{"ACDT": "Austrālijas centrālais vasaras laiks", "ACST": "Austrālijas centrālais ziemas laiks", "ACWDT": "Austrālijas centrālais rietumu vasaras laiks", "ACWST": "Austrālijas centrālais rietumu ziemas laiks", "ADT": "Atlantijas vasaras laiks", "AEDT": "Austrālijas austrumu vasaras laiks", "AEST": "Austrālijas austrumu ziemas laiks", "AKDT": "Aļaskas vasaras laiks", "AKST": "Aļaskas ziemas laiks", "ARST": "Argentīnas vasaras laiks", "ART": "Argentīnas ziemas laiks", "AST": "Atlantijas ziemas laiks", "AWDT": "Austrālijas rietumu vasaras laiks", "AWST": "Austrālijas rietumu ziemas laiks", "BOT": "Bolīvijas laiks", "BT": "Butānas laiks", "CAT": "Centrālāfrikas laiks", "CDT": "Centrālais vasaras laiks", "CHADT": "Četemas vasaras laiks", "CHAST": "Četemas ziemas laiks", "CLST": "Čīles vasaras laiks", "CLT": "Čīles ziemas laiks", "COST": "Kolumbijas vasaras laiks", "COT": "Kolumbijas ziemas laiks", "CST": "Centrālais ziemas laiks", "ChST": "Čamorra ziemas laiks", "EAT": "Austrumāfrikas laiks", "ECT": "Ekvadoras laiks", "EDT": "Austrumu vasaras laiks", "EST": "Austrumu ziemas laiks", "GFT": "Francijas Gviānas laiks", "GMT": "Griničas laiks", "GST": "Persijas līča laiks", "GYT": "Gajānas laiks", "HADT": "Havaju–Aleutu vasaras laiks", "HAST": "Havaju–Aleutu ziemas laiks", "HAT": "Ņūfaundlendas vasaras laiks", "HECU": "Kubas vasaras laiks", "HEEG": "Austrumgrenlandes vasaras laiks", "HENOMX": "Ziemeļrietumu Meksikas vasaras laiks", "HEOG": "Rietumgrenlandes vasaras laiks", "HEPM": "Senpjēras un Mikelonas vasaras laiks", "HEPMX": "Meksikas Klusā okeāna piekrastes vasaras laiks", "HKST": "Honkongas vasaras laiks", "HKT": "Honkongas ziemas laiks", "HNCU": "Kubas ziemas laiks", "HNEG": "Austrumgrenlandes ziemas laiks", "HNNOMX": "Ziemeļrietumu Meksikas ziemas laiks", "HNOG": "Rietumgrenlandes ziemas laiks", "HNPM": "Senpjēras un Mikelonas ziemas laiks", "HNPMX": "Meksikas Klusā okeāna piekrastes ziemas laiks", "HNT": "Ņūfaundlendas ziemas laiks", "IST": "Indijas ziemas laiks", "JDT": "Japānas vasaras laiks", "JST": "Japānas ziemas laiks", "LHDT": "Lorda Hava salas vasaras laiks", "LHST": "Lorda Hava salas ziemas laiks", "MDT": "Kalnu vasaras laiks", "MESZ": "Centrāleiropas vasaras laiks", "MEZ": "Centrāleiropas ziemas laiks", "MST": "Kalnu ziemas laiks", "MYT": "Malaizijas laiks", "NZDT": "Jaunzēlandes vasaras laiks", "NZST": "Jaunzēlandes ziemas laiks", "OESZ": "Austrumeiropas vasaras laiks", "OEZ": "Austrumeiropas ziemas laiks", "PDT": "Klusā okeāna vasaras laiks", "PST": "Klusā okeāna ziemas laiks", "SAST": "Dienvidāfrikas ziemas laiks", "SGT": "Singapūras laiks", "SRT": "Surinamas laiks", "TMST": "Turkmenistānas vasaras laiks", "TMT": "Turkmenistānas ziemas laiks", "UYST": "Urugvajas vasaras laiks", "UYT": "Urugvajas ziemas laiks", "VET": "Venecuēlas laiks", "WARST": "Rietumargentīnas vasaras laiks", "WART": "Rietumargentīnas ziemas laiks", "WAST": "Rietumāfrikas vasaras laiks", "WAT": "Rietumāfrikas ziemas laiks", "WESZ": "Rietumeiropas vasaras laiks", "WEZ": "Rietumeiropas ziemas laiks", "WIB": "Rietumindonēzijas laiks", "WIT": "Austrumindonēzijas laiks", "WITA": "Centrālindonēzijas laiks", "∅∅∅": "Brazīlijas vasaras laiks"}, 75 } 76} 77 78// Locale returns the current translators string locale 79func (lv *lv_LV) Locale() string { 80 return lv.locale 81} 82 83// PluralsCardinal returns the list of cardinal plural rules associated with 'lv_LV' 84func (lv *lv_LV) PluralsCardinal() []locales.PluralRule { 85 return lv.pluralsCardinal 86} 87 88// PluralsOrdinal returns the list of ordinal plural rules associated with 'lv_LV' 89func (lv *lv_LV) PluralsOrdinal() []locales.PluralRule { 90 return lv.pluralsOrdinal 91} 92 93// PluralsRange returns the list of range plural rules associated with 'lv_LV' 94func (lv *lv_LV) PluralsRange() []locales.PluralRule { 95 return lv.pluralsRange 96} 97 98// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'lv_LV' 99func (lv *lv_LV) CardinalPluralRule(num float64, v uint64) locales.PluralRule { 100 101 n := math.Abs(num) 102 f := locales.F(n, v) 103 nMod10 := math.Mod(n, 10) 104 nMod100 := math.Mod(n, 100) 105 fMod10 := f % 10 106 fMod100 := f % 100 107 108 if (nMod10 == 0) || (nMod100 >= 11 && nMod100 <= 19) || (v == 2 && fMod100 >= 11 && fMod100 <= 19) { 109 return locales.PluralRuleZero 110 } else if (nMod10 == 1 && nMod100 != 11) || (v == 2 && fMod10 == 1 && fMod100 != 11) || (v != 2 && fMod10 == 1) { 111 return locales.PluralRuleOne 112 } 113 114 return locales.PluralRuleOther 115} 116 117// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'lv_LV' 118func (lv *lv_LV) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 119 return locales.PluralRuleOther 120} 121 122// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'lv_LV' 123func (lv *lv_LV) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 124 125 start := lv.CardinalPluralRule(num1, v1) 126 end := lv.CardinalPluralRule(num2, v2) 127 128 if start == locales.PluralRuleZero && end == locales.PluralRuleZero { 129 return locales.PluralRuleOther 130 } else if start == locales.PluralRuleZero && end == locales.PluralRuleOne { 131 return locales.PluralRuleOne 132 } else if start == locales.PluralRuleZero && end == locales.PluralRuleOther { 133 return locales.PluralRuleOther 134 } else if start == locales.PluralRuleOne && end == locales.PluralRuleZero { 135 return locales.PluralRuleOther 136 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOne { 137 return locales.PluralRuleOne 138 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther { 139 return locales.PluralRuleOther 140 } else if start == locales.PluralRuleOther && end == locales.PluralRuleZero { 141 return locales.PluralRuleOther 142 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { 143 return locales.PluralRuleOne 144 } 145 146 return locales.PluralRuleOther 147 148} 149 150// MonthAbbreviated returns the locales abbreviated month given the 'month' provided 151func (lv *lv_LV) MonthAbbreviated(month time.Month) string { 152 return lv.monthsAbbreviated[month] 153} 154 155// MonthsAbbreviated returns the locales abbreviated months 156func (lv *lv_LV) MonthsAbbreviated() []string { 157 return lv.monthsAbbreviated[1:] 158} 159 160// MonthNarrow returns the locales narrow month given the 'month' provided 161func (lv *lv_LV) MonthNarrow(month time.Month) string { 162 return lv.monthsNarrow[month] 163} 164 165// MonthsNarrow returns the locales narrow months 166func (lv *lv_LV) MonthsNarrow() []string { 167 return lv.monthsNarrow[1:] 168} 169 170// MonthWide returns the locales wide month given the 'month' provided 171func (lv *lv_LV) MonthWide(month time.Month) string { 172 return lv.monthsWide[month] 173} 174 175// MonthsWide returns the locales wide months 176func (lv *lv_LV) MonthsWide() []string { 177 return lv.monthsWide[1:] 178} 179 180// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided 181func (lv *lv_LV) WeekdayAbbreviated(weekday time.Weekday) string { 182 return lv.daysAbbreviated[weekday] 183} 184 185// WeekdaysAbbreviated returns the locales abbreviated weekdays 186func (lv *lv_LV) WeekdaysAbbreviated() []string { 187 return lv.daysAbbreviated 188} 189 190// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided 191func (lv *lv_LV) WeekdayNarrow(weekday time.Weekday) string { 192 return lv.daysNarrow[weekday] 193} 194 195// WeekdaysNarrow returns the locales narrow weekdays 196func (lv *lv_LV) WeekdaysNarrow() []string { 197 return lv.daysNarrow 198} 199 200// WeekdayShort returns the locales short weekday given the 'weekday' provided 201func (lv *lv_LV) WeekdayShort(weekday time.Weekday) string { 202 return lv.daysShort[weekday] 203} 204 205// WeekdaysShort returns the locales short weekdays 206func (lv *lv_LV) WeekdaysShort() []string { 207 return lv.daysShort 208} 209 210// WeekdayWide returns the locales wide weekday given the 'weekday' provided 211func (lv *lv_LV) WeekdayWide(weekday time.Weekday) string { 212 return lv.daysWide[weekday] 213} 214 215// WeekdaysWide returns the locales wide weekdays 216func (lv *lv_LV) WeekdaysWide() []string { 217 return lv.daysWide 218} 219 220// Decimal returns the decimal point of number 221func (lv *lv_LV) Decimal() string { 222 return lv.decimal 223} 224 225// Group returns the group of number 226func (lv *lv_LV) Group() string { 227 return lv.group 228} 229 230// Group returns the minus sign of number 231func (lv *lv_LV) Minus() string { 232 return lv.minus 233} 234 235// FmtNumber returns 'num' with digits/precision of 'v' for 'lv_LV' and handles both Whole and Real numbers based on 'v' 236func (lv *lv_LV) FmtNumber(num float64, v uint64) string { 237 238 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 239 l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3 240 count := 0 241 inWhole := v == 0 242 b := make([]byte, 0, l) 243 244 for i := len(s) - 1; i >= 0; i-- { 245 246 if s[i] == '.' { 247 b = append(b, lv.decimal[0]) 248 inWhole = true 249 continue 250 } 251 252 if inWhole { 253 if count == 3 { 254 for j := len(lv.group) - 1; j >= 0; j-- { 255 b = append(b, lv.group[j]) 256 } 257 count = 1 258 } else { 259 count++ 260 } 261 } 262 263 b = append(b, s[i]) 264 } 265 266 if num < 0 { 267 b = append(b, lv.minus[0]) 268 } 269 270 // reverse 271 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 272 b[i], b[j] = b[j], b[i] 273 } 274 275 return string(b) 276} 277 278// FmtPercent returns 'num' with digits/precision of 'v' for 'lv_LV' and handles both Whole and Real numbers based on 'v' 279// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 280func (lv *lv_LV) FmtPercent(num float64, v uint64) string { 281 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 282 l := len(s) + 3 283 b := make([]byte, 0, l) 284 285 for i := len(s) - 1; i >= 0; i-- { 286 287 if s[i] == '.' { 288 b = append(b, lv.decimal[0]) 289 continue 290 } 291 292 b = append(b, s[i]) 293 } 294 295 if num < 0 { 296 b = append(b, lv.minus[0]) 297 } 298 299 // reverse 300 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 301 b[i], b[j] = b[j], b[i] 302 } 303 304 b = append(b, lv.percent...) 305 306 return string(b) 307} 308 309// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'lv_LV' 310func (lv *lv_LV) FmtCurrency(num float64, v uint64, currency currency.Type) string { 311 312 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 313 symbol := lv.currencies[currency] 314 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 315 count := 0 316 inWhole := v == 0 317 b := make([]byte, 0, l) 318 319 for i := len(s) - 1; i >= 0; i-- { 320 321 if s[i] == '.' { 322 b = append(b, lv.decimal[0]) 323 inWhole = true 324 continue 325 } 326 327 if inWhole { 328 if count == 3 { 329 for j := len(lv.group) - 1; j >= 0; j-- { 330 b = append(b, lv.group[j]) 331 } 332 count = 1 333 } else { 334 count++ 335 } 336 } 337 338 b = append(b, s[i]) 339 } 340 341 if num < 0 { 342 b = append(b, lv.minus[0]) 343 } 344 345 // reverse 346 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 347 b[i], b[j] = b[j], b[i] 348 } 349 350 if int(v) < 2 { 351 352 if v == 0 { 353 b = append(b, lv.decimal...) 354 } 355 356 for i := 0; i < 2-int(v); i++ { 357 b = append(b, '0') 358 } 359 } 360 361 b = append(b, lv.currencyPositiveSuffix...) 362 363 b = append(b, symbol...) 364 365 return string(b) 366} 367 368// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'lv_LV' 369// in accounting notation. 370func (lv *lv_LV) FmtAccounting(num float64, v uint64, currency currency.Type) string { 371 372 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 373 symbol := lv.currencies[currency] 374 l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3 375 count := 0 376 inWhole := v == 0 377 b := make([]byte, 0, l) 378 379 for i := len(s) - 1; i >= 0; i-- { 380 381 if s[i] == '.' { 382 b = append(b, lv.decimal[0]) 383 inWhole = true 384 continue 385 } 386 387 if inWhole { 388 if count == 3 { 389 for j := len(lv.group) - 1; j >= 0; j-- { 390 b = append(b, lv.group[j]) 391 } 392 count = 1 393 } else { 394 count++ 395 } 396 } 397 398 b = append(b, s[i]) 399 } 400 401 if num < 0 { 402 403 b = append(b, lv.minus[0]) 404 405 } 406 407 // reverse 408 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 409 b[i], b[j] = b[j], b[i] 410 } 411 412 if int(v) < 2 { 413 414 if v == 0 { 415 b = append(b, lv.decimal...) 416 } 417 418 for i := 0; i < 2-int(v); i++ { 419 b = append(b, '0') 420 } 421 } 422 423 if num < 0 { 424 b = append(b, lv.currencyNegativeSuffix...) 425 b = append(b, symbol...) 426 } else { 427 428 b = append(b, lv.currencyPositiveSuffix...) 429 b = append(b, symbol...) 430 } 431 432 return string(b) 433} 434 435// FmtDateShort returns the short date representation of 't' for 'lv_LV' 436func (lv *lv_LV) FmtDateShort(t time.Time) string { 437 438 b := make([]byte, 0, 32) 439 440 if t.Day() < 10 { 441 b = append(b, '0') 442 } 443 444 b = strconv.AppendInt(b, int64(t.Day()), 10) 445 b = append(b, []byte{0x2e}...) 446 447 if t.Month() < 10 { 448 b = append(b, '0') 449 } 450 451 b = strconv.AppendInt(b, int64(t.Month()), 10) 452 453 b = append(b, []byte{0x2e}...) 454 455 if t.Year() > 9 { 456 b = append(b, strconv.Itoa(t.Year())[2:]...) 457 } else { 458 b = append(b, strconv.Itoa(t.Year())[1:]...) 459 } 460 461 return string(b) 462} 463 464// FmtDateMedium returns the medium date representation of 't' for 'lv_LV' 465func (lv *lv_LV) FmtDateMedium(t time.Time) string { 466 467 b := make([]byte, 0, 32) 468 469 if t.Year() > 0 { 470 b = strconv.AppendInt(b, int64(t.Year()), 10) 471 } else { 472 b = strconv.AppendInt(b, int64(-t.Year()), 10) 473 } 474 475 b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) 476 b = append(b, []byte{0x20}...) 477 b = strconv.AppendInt(b, int64(t.Day()), 10) 478 b = append(b, []byte{0x2e, 0x20}...) 479 b = append(b, lv.monthsAbbreviated[t.Month()]...) 480 481 return string(b) 482} 483 484// FmtDateLong returns the long date representation of 't' for 'lv_LV' 485func (lv *lv_LV) FmtDateLong(t time.Time) string { 486 487 b := make([]byte, 0, 32) 488 489 if t.Year() > 0 { 490 b = strconv.AppendInt(b, int64(t.Year()), 10) 491 } else { 492 b = strconv.AppendInt(b, int64(-t.Year()), 10) 493 } 494 495 b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) 496 b = append(b, []byte{0x20}...) 497 b = strconv.AppendInt(b, int64(t.Day()), 10) 498 b = append(b, []byte{0x2e, 0x20}...) 499 b = append(b, lv.monthsWide[t.Month()]...) 500 501 return string(b) 502} 503 504// FmtDateFull returns the full date representation of 't' for 'lv_LV' 505func (lv *lv_LV) FmtDateFull(t time.Time) string { 506 507 b := make([]byte, 0, 32) 508 509 b = append(b, lv.daysWide[t.Weekday()]...) 510 b = append(b, []byte{0x2c, 0x20}...) 511 512 if t.Year() > 0 { 513 b = strconv.AppendInt(b, int64(t.Year()), 10) 514 } else { 515 b = strconv.AppendInt(b, int64(-t.Year()), 10) 516 } 517 518 b = append(b, []byte{0x2e, 0x20, 0x67, 0x61, 0x64, 0x61}...) 519 b = append(b, []byte{0x20}...) 520 b = strconv.AppendInt(b, int64(t.Day()), 10) 521 b = append(b, []byte{0x2e, 0x20}...) 522 b = append(b, lv.monthsWide[t.Month()]...) 523 524 return string(b) 525} 526 527// FmtTimeShort returns the short time representation of 't' for 'lv_LV' 528func (lv *lv_LV) FmtTimeShort(t time.Time) string { 529 530 b := make([]byte, 0, 32) 531 532 if t.Hour() < 10 { 533 b = append(b, '0') 534 } 535 536 b = strconv.AppendInt(b, int64(t.Hour()), 10) 537 b = append(b, lv.timeSeparator...) 538 539 if t.Minute() < 10 { 540 b = append(b, '0') 541 } 542 543 b = strconv.AppendInt(b, int64(t.Minute()), 10) 544 545 return string(b) 546} 547 548// FmtTimeMedium returns the medium time representation of 't' for 'lv_LV' 549func (lv *lv_LV) FmtTimeMedium(t time.Time) string { 550 551 b := make([]byte, 0, 32) 552 553 if t.Hour() < 10 { 554 b = append(b, '0') 555 } 556 557 b = strconv.AppendInt(b, int64(t.Hour()), 10) 558 b = append(b, lv.timeSeparator...) 559 560 if t.Minute() < 10 { 561 b = append(b, '0') 562 } 563 564 b = strconv.AppendInt(b, int64(t.Minute()), 10) 565 b = append(b, lv.timeSeparator...) 566 567 if t.Second() < 10 { 568 b = append(b, '0') 569 } 570 571 b = strconv.AppendInt(b, int64(t.Second()), 10) 572 573 return string(b) 574} 575 576// FmtTimeLong returns the long time representation of 't' for 'lv_LV' 577func (lv *lv_LV) FmtTimeLong(t time.Time) string { 578 579 b := make([]byte, 0, 32) 580 581 if t.Hour() < 10 { 582 b = append(b, '0') 583 } 584 585 b = strconv.AppendInt(b, int64(t.Hour()), 10) 586 b = append(b, lv.timeSeparator...) 587 588 if t.Minute() < 10 { 589 b = append(b, '0') 590 } 591 592 b = strconv.AppendInt(b, int64(t.Minute()), 10) 593 b = append(b, lv.timeSeparator...) 594 595 if t.Second() < 10 { 596 b = append(b, '0') 597 } 598 599 b = strconv.AppendInt(b, int64(t.Second()), 10) 600 b = append(b, []byte{0x20}...) 601 602 tz, _ := t.Zone() 603 b = append(b, tz...) 604 605 return string(b) 606} 607 608// FmtTimeFull returns the full time representation of 't' for 'lv_LV' 609func (lv *lv_LV) FmtTimeFull(t time.Time) string { 610 611 b := make([]byte, 0, 32) 612 613 if t.Hour() < 10 { 614 b = append(b, '0') 615 } 616 617 b = strconv.AppendInt(b, int64(t.Hour()), 10) 618 b = append(b, lv.timeSeparator...) 619 620 if t.Minute() < 10 { 621 b = append(b, '0') 622 } 623 624 b = strconv.AppendInt(b, int64(t.Minute()), 10) 625 b = append(b, lv.timeSeparator...) 626 627 if t.Second() < 10 { 628 b = append(b, '0') 629 } 630 631 b = strconv.AppendInt(b, int64(t.Second()), 10) 632 b = append(b, []byte{0x20}...) 633 634 tz, _ := t.Zone() 635 636 if btz, ok := lv.timezones[tz]; ok { 637 b = append(b, btz...) 638 } else { 639 b = append(b, tz...) 640 } 641 642 return string(b) 643} 644