...

Source file src/github.com/go-playground/locales/lt_LT/lt_LT.go

Documentation: github.com/go-playground/locales/lt_LT

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

View as plain text