...

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

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

     1  package pt_LU
     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 pt_LU 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  	currencyNegativePrefix 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 'pt_LU' locale
    46  func New() locales.Translator {
    47  	return &pt_LU{
    48  		locale:                 "pt_LU",
    49  		pluralsCardinal:        []locales.PluralRule{2, 6},
    50  		pluralsOrdinal:         []locales.PluralRule{6},
    51  		pluralsRange:           []locales.PluralRule{2, 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", "F", "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  		currencyPositiveSuffix: " ",
    61  		currencyNegativePrefix: "(",
    62  		currencyNegativeSuffix: " )",
    63  		monthsAbbreviated:      []string{"", "jan.", "fev.", "mar.", "abr.", "mai.", "jun.", "jul.", "ago.", "set.", "out.", "nov.", "dez."},
    64  		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
    65  		monthsWide:             []string{"", "janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"},
    66  		daysAbbreviated:        []string{"domingo", "segunda", "terça", "quarta", "quinta", "sexta", "sábado"},
    67  		daysNarrow:             []string{"D", "S", "T", "Q", "Q", "S", "S"},
    68  		daysWide:               []string{"domingo", "segunda-feira", "terça-feira", "quarta-feira", "quinta-feira", "sexta-feira", "sábado"},
    69  		periodsAbbreviated:     []string{"a.m.", "p.m."},
    70  		periodsNarrow:          []string{"a.m.", "p.m."},
    71  		periodsWide:            []string{"da manhã", "da tarde"},
    72  		erasAbbreviated:        []string{"a.E.C.", "E.C."},
    73  		erasNarrow:             []string{"", ""},
    74  		erasWide:               []string{"", ""},
    75  		timezones:              map[string]string{"ACDT": "Hora de verão da Austrália Central", "ACST": "Hora padrão da Austrália Central", "ACWDT": "Hora de verão da Austrália Central Ocidental", "ACWST": "Hora padrão da Austrália Central Ocidental", "ADT": "Hora de verão do Atlântico", "AEDT": "Hora de verão da Austrália Oriental", "AEST": "Hora padrão da Austrália Oriental", "AKDT": "Hora de verão do Alasca", "AKST": "Hora padrão do Alasca", "ARST": "Hora de verão da Argentina", "ART": "Hora padrão da Argentina", "AST": "Hora padrão do Atlântico", "AWDT": "Hora de verão da Austrália Ocidental", "AWST": "Hora padrão da Austrália Ocidental", "BOT": "Hora da Bolívia", "BT": "Hora do Butão", "CAT": "Hora da África Central", "CDT": "Hora de verão central norte-americana", "CHADT": "Hora de verão de Chatham", "CHAST": "Hora padrão de Chatham", "CLST": "Hora de verão do Chile", "CLT": "Hora padrão do Chile", "COST": "Hora de verão da Colômbia", "COT": "Hora padrão da Colômbia", "CST": "Hora padrão central norte-americana", "ChST": "Hora padrão de Chamorro", "EAT": "Hora da África Oriental", "ECT": "Hora do Equador", "EDT": "Hora de verão oriental norte-americana", "EST": "Hora padrão oriental norte-americana", "GFT": "Hora da Guiana Francesa", "GMT": "Hora de Greenwich", "GST": "Hora padrão do Golfo", "GYT": "Hora da Guiana", "HADT": "Hora de verão do Havai e Aleutas", "HAST": "Hora padrão do Havai e Aleutas", "HAT": "Hora de verão da Terra Nova", "HECU": "Hora de verão de Cuba", "HEEG": "Hora de verão da Gronelândia Oriental", "HENOMX": "Hora de verão do Noroeste do México", "HEOG": "Hora de verão da Gronelândia Ocidental", "HEPM": "Hora de verão de São Pedro e Miquelão", "HEPMX": "Hora de verão do Pacífico Mexicano", "HKST": "Hora de verão de Hong Kong", "HKT": "Hora padrão de Hong Kong", "HNCU": "Hora padrão de Cuba", "HNEG": "Hora padrão da Gronelândia Oriental", "HNNOMX": "Hora padrão do Noroeste do México", "HNOG": "Hora padrão da Gronelândia Ocidental", "HNPM": "Hora padrão de São Pedro e Miquelão", "HNPMX": "Hora padrão do Pacífico Mexicano", "HNT": "Hora padrão da Terra Nova", "IST": "Hora padrão da Índia", "JDT": "Hora de verão do Japão", "JST": "Hora padrão do Japão", "LHDT": "Hora de verão de Lord Howe", "LHST": "Hora padrão de Lord Howe", "MDT": "Hora de verão de montanha norte-americana", "MESZ": "Hora de verão da Europa Central", "MEZ": "Hora padrão da Europa Central", "MST": "Hora padrão de montanha norte-americana", "MYT": "Hora da Malásia", "NZDT": "Hora de verão da Nova Zelândia", "NZST": "Hora padrão da Nova Zelândia", "OESZ": "Hora de verão da Europa Oriental", "OEZ": "Hora padrão da Europa Oriental", "PDT": "Hora de verão do Pacífico norte-americana", "PST": "Hora padrão do Pacífico norte-americana", "SAST": "Hora da África do Sul", "SGT": "Hora padrão de Singapura", "SRT": "Hora do Suriname", "TMST": "Hora de verão do Turquemenistão", "TMT": "Hora padrão do Turquemenistão", "UYST": "Hora de verão do Uruguai", "UYT": "Hora padrão do Uruguai", "VET": "Hora da Venezuela", "WARST": "Hora de verão da Argentina Ocidental", "WART": "Hora padrão da Argentina Ocidental", "WAST": "Hora de verão da África Ocidental", "WAT": "Hora padrão da África Ocidental", "WESZ": "Hora de verão da Europa Ocidental", "WEZ": "Hora padrão da Europa Ocidental", "WIB": "Hora da Indonésia Ocidental", "WIT": "Hora da Indonésia Oriental", "WITA": "Hora da Indonésia Central", "∅∅∅": "Hora de verão do Amazonas"},
    76  	}
    77  }
    78  
    79  // Locale returns the current translators string locale
    80  func (pt *pt_LU) Locale() string {
    81  	return pt.locale
    82  }
    83  
    84  // PluralsCardinal returns the list of cardinal plural rules associated with 'pt_LU'
    85  func (pt *pt_LU) PluralsCardinal() []locales.PluralRule {
    86  	return pt.pluralsCardinal
    87  }
    88  
    89  // PluralsOrdinal returns the list of ordinal plural rules associated with 'pt_LU'
    90  func (pt *pt_LU) PluralsOrdinal() []locales.PluralRule {
    91  	return pt.pluralsOrdinal
    92  }
    93  
    94  // PluralsRange returns the list of range plural rules associated with 'pt_LU'
    95  func (pt *pt_LU) PluralsRange() []locales.PluralRule {
    96  	return pt.pluralsRange
    97  }
    98  
    99  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pt_LU'
   100  func (pt *pt_LU) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   101  
   102  	n := math.Abs(num)
   103  	i := int64(n)
   104  
   105  	if i >= 0 && i <= 1 {
   106  		return locales.PluralRuleOne
   107  	}
   108  
   109  	return locales.PluralRuleOther
   110  }
   111  
   112  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pt_LU'
   113  func (pt *pt_LU) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   114  	return locales.PluralRuleOther
   115  }
   116  
   117  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pt_LU'
   118  func (pt *pt_LU) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   119  
   120  	start := pt.CardinalPluralRule(num1, v1)
   121  	end := pt.CardinalPluralRule(num2, v2)
   122  
   123  	if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
   124  		return locales.PluralRuleOne
   125  	} else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
   126  		return locales.PluralRuleOther
   127  	}
   128  
   129  	return locales.PluralRuleOther
   130  
   131  }
   132  
   133  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   134  func (pt *pt_LU) MonthAbbreviated(month time.Month) string {
   135  	return pt.monthsAbbreviated[month]
   136  }
   137  
   138  // MonthsAbbreviated returns the locales abbreviated months
   139  func (pt *pt_LU) MonthsAbbreviated() []string {
   140  	return pt.monthsAbbreviated[1:]
   141  }
   142  
   143  // MonthNarrow returns the locales narrow month given the 'month' provided
   144  func (pt *pt_LU) MonthNarrow(month time.Month) string {
   145  	return pt.monthsNarrow[month]
   146  }
   147  
   148  // MonthsNarrow returns the locales narrow months
   149  func (pt *pt_LU) MonthsNarrow() []string {
   150  	return pt.monthsNarrow[1:]
   151  }
   152  
   153  // MonthWide returns the locales wide month given the 'month' provided
   154  func (pt *pt_LU) MonthWide(month time.Month) string {
   155  	return pt.monthsWide[month]
   156  }
   157  
   158  // MonthsWide returns the locales wide months
   159  func (pt *pt_LU) MonthsWide() []string {
   160  	return pt.monthsWide[1:]
   161  }
   162  
   163  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   164  func (pt *pt_LU) WeekdayAbbreviated(weekday time.Weekday) string {
   165  	return pt.daysAbbreviated[weekday]
   166  }
   167  
   168  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   169  func (pt *pt_LU) WeekdaysAbbreviated() []string {
   170  	return pt.daysAbbreviated
   171  }
   172  
   173  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   174  func (pt *pt_LU) WeekdayNarrow(weekday time.Weekday) string {
   175  	return pt.daysNarrow[weekday]
   176  }
   177  
   178  // WeekdaysNarrow returns the locales narrow weekdays
   179  func (pt *pt_LU) WeekdaysNarrow() []string {
   180  	return pt.daysNarrow
   181  }
   182  
   183  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   184  func (pt *pt_LU) WeekdayShort(weekday time.Weekday) string {
   185  	return pt.daysShort[weekday]
   186  }
   187  
   188  // WeekdaysShort returns the locales short weekdays
   189  func (pt *pt_LU) WeekdaysShort() []string {
   190  	return pt.daysShort
   191  }
   192  
   193  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   194  func (pt *pt_LU) WeekdayWide(weekday time.Weekday) string {
   195  	return pt.daysWide[weekday]
   196  }
   197  
   198  // WeekdaysWide returns the locales wide weekdays
   199  func (pt *pt_LU) WeekdaysWide() []string {
   200  	return pt.daysWide
   201  }
   202  
   203  // Decimal returns the decimal point of number
   204  func (pt *pt_LU) Decimal() string {
   205  	return pt.decimal
   206  }
   207  
   208  // Group returns the group of number
   209  func (pt *pt_LU) Group() string {
   210  	return pt.group
   211  }
   212  
   213  // Group returns the minus sign of number
   214  func (pt *pt_LU) Minus() string {
   215  	return pt.minus
   216  }
   217  
   218  // FmtNumber returns 'num' with digits/precision of 'v' for 'pt_LU' and handles both Whole and Real numbers based on 'v'
   219  func (pt *pt_LU) FmtNumber(num float64, v uint64) string {
   220  
   221  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   222  	l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
   223  	count := 0
   224  	inWhole := v == 0
   225  	b := make([]byte, 0, l)
   226  
   227  	for i := len(s) - 1; i >= 0; i-- {
   228  
   229  		if s[i] == '.' {
   230  			b = append(b, pt.decimal[0])
   231  			inWhole = true
   232  			continue
   233  		}
   234  
   235  		if inWhole {
   236  			if count == 3 {
   237  				for j := len(pt.group) - 1; j >= 0; j-- {
   238  					b = append(b, pt.group[j])
   239  				}
   240  				count = 1
   241  			} else {
   242  				count++
   243  			}
   244  		}
   245  
   246  		b = append(b, s[i])
   247  	}
   248  
   249  	if num < 0 {
   250  		b = append(b, pt.minus[0])
   251  	}
   252  
   253  	// reverse
   254  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   255  		b[i], b[j] = b[j], b[i]
   256  	}
   257  
   258  	return string(b)
   259  }
   260  
   261  // FmtPercent returns 'num' with digits/precision of 'v' for 'pt_LU' and handles both Whole and Real numbers based on 'v'
   262  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   263  func (pt *pt_LU) FmtPercent(num float64, v uint64) string {
   264  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   265  	l := len(s) + 3
   266  	b := make([]byte, 0, l)
   267  
   268  	for i := len(s) - 1; i >= 0; i-- {
   269  
   270  		if s[i] == '.' {
   271  			b = append(b, pt.decimal[0])
   272  			continue
   273  		}
   274  
   275  		b = append(b, s[i])
   276  	}
   277  
   278  	if num < 0 {
   279  		b = append(b, pt.minus[0])
   280  	}
   281  
   282  	// reverse
   283  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   284  		b[i], b[j] = b[j], b[i]
   285  	}
   286  
   287  	b = append(b, pt.percent...)
   288  
   289  	return string(b)
   290  }
   291  
   292  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pt_LU'
   293  func (pt *pt_LU) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   294  
   295  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   296  	symbol := pt.currencies[currency]
   297  	l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
   298  	count := 0
   299  	inWhole := v == 0
   300  	b := make([]byte, 0, l)
   301  
   302  	for i := len(s) - 1; i >= 0; i-- {
   303  
   304  		if s[i] == '.' {
   305  			b = append(b, pt.decimal[0])
   306  			inWhole = true
   307  			continue
   308  		}
   309  
   310  		if inWhole {
   311  			if count == 3 {
   312  				for j := len(pt.group) - 1; j >= 0; j-- {
   313  					b = append(b, pt.group[j])
   314  				}
   315  				count = 1
   316  			} else {
   317  				count++
   318  			}
   319  		}
   320  
   321  		b = append(b, s[i])
   322  	}
   323  
   324  	if num < 0 {
   325  		b = append(b, pt.minus[0])
   326  	}
   327  
   328  	// reverse
   329  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   330  		b[i], b[j] = b[j], b[i]
   331  	}
   332  
   333  	if int(v) < 2 {
   334  
   335  		if v == 0 {
   336  			b = append(b, pt.decimal...)
   337  		}
   338  
   339  		for i := 0; i < 2-int(v); i++ {
   340  			b = append(b, '0')
   341  		}
   342  	}
   343  
   344  	b = append(b, pt.currencyPositiveSuffix...)
   345  
   346  	b = append(b, symbol...)
   347  
   348  	return string(b)
   349  }
   350  
   351  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pt_LU'
   352  // in accounting notation.
   353  func (pt *pt_LU) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   354  
   355  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   356  	symbol := pt.currencies[currency]
   357  	l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
   358  	count := 0
   359  	inWhole := v == 0
   360  	b := make([]byte, 0, l)
   361  
   362  	for i := len(s) - 1; i >= 0; i-- {
   363  
   364  		if s[i] == '.' {
   365  			b = append(b, pt.decimal[0])
   366  			inWhole = true
   367  			continue
   368  		}
   369  
   370  		if inWhole {
   371  			if count == 3 {
   372  				for j := len(pt.group) - 1; j >= 0; j-- {
   373  					b = append(b, pt.group[j])
   374  				}
   375  				count = 1
   376  			} else {
   377  				count++
   378  			}
   379  		}
   380  
   381  		b = append(b, s[i])
   382  	}
   383  
   384  	if num < 0 {
   385  
   386  		b = append(b, pt.currencyNegativePrefix[0])
   387  
   388  	}
   389  
   390  	// reverse
   391  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   392  		b[i], b[j] = b[j], b[i]
   393  	}
   394  
   395  	if int(v) < 2 {
   396  
   397  		if v == 0 {
   398  			b = append(b, pt.decimal...)
   399  		}
   400  
   401  		for i := 0; i < 2-int(v); i++ {
   402  			b = append(b, '0')
   403  		}
   404  	}
   405  
   406  	if num < 0 {
   407  		b = append(b, pt.currencyNegativeSuffix...)
   408  		b = append(b, symbol...)
   409  	} else {
   410  
   411  		b = append(b, pt.currencyPositiveSuffix...)
   412  		b = append(b, symbol...)
   413  	}
   414  
   415  	return string(b)
   416  }
   417  
   418  // FmtDateShort returns the short date representation of 't' for 'pt_LU'
   419  func (pt *pt_LU) FmtDateShort(t time.Time) string {
   420  
   421  	b := make([]byte, 0, 32)
   422  
   423  	if t.Day() < 10 {
   424  		b = append(b, '0')
   425  	}
   426  
   427  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   428  	b = append(b, []byte{0x2f}...)
   429  
   430  	if t.Month() < 10 {
   431  		b = append(b, '0')
   432  	}
   433  
   434  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   435  
   436  	b = append(b, []byte{0x2f}...)
   437  
   438  	if t.Year() > 9 {
   439  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   440  	} else {
   441  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   442  	}
   443  
   444  	return string(b)
   445  }
   446  
   447  // FmtDateMedium returns the medium date representation of 't' for 'pt_LU'
   448  func (pt *pt_LU) FmtDateMedium(t time.Time) string {
   449  
   450  	b := make([]byte, 0, 32)
   451  
   452  	if t.Day() < 10 {
   453  		b = append(b, '0')
   454  	}
   455  
   456  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   457  	b = append(b, []byte{0x2f}...)
   458  
   459  	if t.Month() < 10 {
   460  		b = append(b, '0')
   461  	}
   462  
   463  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   464  
   465  	b = append(b, []byte{0x2f}...)
   466  
   467  	if t.Year() > 0 {
   468  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   469  	} else {
   470  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   471  	}
   472  
   473  	return string(b)
   474  }
   475  
   476  // FmtDateLong returns the long date representation of 't' for 'pt_LU'
   477  func (pt *pt_LU) FmtDateLong(t time.Time) string {
   478  
   479  	b := make([]byte, 0, 32)
   480  
   481  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   482  	b = append(b, []byte{0x20, 0x64, 0x65}...)
   483  	b = append(b, []byte{0x20}...)
   484  	b = append(b, pt.monthsWide[t.Month()]...)
   485  	b = append(b, []byte{0x20, 0x64, 0x65}...)
   486  	b = append(b, []byte{0x20}...)
   487  
   488  	if t.Year() > 0 {
   489  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   490  	} else {
   491  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   492  	}
   493  
   494  	return string(b)
   495  }
   496  
   497  // FmtDateFull returns the full date representation of 't' for 'pt_LU'
   498  func (pt *pt_LU) FmtDateFull(t time.Time) string {
   499  
   500  	b := make([]byte, 0, 32)
   501  
   502  	b = append(b, pt.daysWide[t.Weekday()]...)
   503  	b = append(b, []byte{0x2c, 0x20}...)
   504  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   505  	b = append(b, []byte{0x20, 0x64, 0x65}...)
   506  	b = append(b, []byte{0x20}...)
   507  	b = append(b, pt.monthsWide[t.Month()]...)
   508  	b = append(b, []byte{0x20, 0x64, 0x65}...)
   509  	b = append(b, []byte{0x20}...)
   510  
   511  	if t.Year() > 0 {
   512  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   513  	} else {
   514  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   515  	}
   516  
   517  	return string(b)
   518  }
   519  
   520  // FmtTimeShort returns the short time representation of 't' for 'pt_LU'
   521  func (pt *pt_LU) FmtTimeShort(t time.Time) string {
   522  
   523  	b := make([]byte, 0, 32)
   524  
   525  	if t.Hour() < 10 {
   526  		b = append(b, '0')
   527  	}
   528  
   529  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   530  	b = append(b, pt.timeSeparator...)
   531  
   532  	if t.Minute() < 10 {
   533  		b = append(b, '0')
   534  	}
   535  
   536  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   537  
   538  	return string(b)
   539  }
   540  
   541  // FmtTimeMedium returns the medium time representation of 't' for 'pt_LU'
   542  func (pt *pt_LU) FmtTimeMedium(t time.Time) string {
   543  
   544  	b := make([]byte, 0, 32)
   545  
   546  	if t.Hour() < 10 {
   547  		b = append(b, '0')
   548  	}
   549  
   550  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   551  	b = append(b, pt.timeSeparator...)
   552  
   553  	if t.Minute() < 10 {
   554  		b = append(b, '0')
   555  	}
   556  
   557  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   558  	b = append(b, pt.timeSeparator...)
   559  
   560  	if t.Second() < 10 {
   561  		b = append(b, '0')
   562  	}
   563  
   564  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   565  
   566  	return string(b)
   567  }
   568  
   569  // FmtTimeLong returns the long time representation of 't' for 'pt_LU'
   570  func (pt *pt_LU) FmtTimeLong(t time.Time) string {
   571  
   572  	b := make([]byte, 0, 32)
   573  
   574  	if t.Hour() < 10 {
   575  		b = append(b, '0')
   576  	}
   577  
   578  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   579  	b = append(b, pt.timeSeparator...)
   580  
   581  	if t.Minute() < 10 {
   582  		b = append(b, '0')
   583  	}
   584  
   585  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   586  	b = append(b, pt.timeSeparator...)
   587  
   588  	if t.Second() < 10 {
   589  		b = append(b, '0')
   590  	}
   591  
   592  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   593  	b = append(b, []byte{0x20}...)
   594  
   595  	tz, _ := t.Zone()
   596  	b = append(b, tz...)
   597  
   598  	return string(b)
   599  }
   600  
   601  // FmtTimeFull returns the full time representation of 't' for 'pt_LU'
   602  func (pt *pt_LU) FmtTimeFull(t time.Time) string {
   603  
   604  	b := make([]byte, 0, 32)
   605  
   606  	if t.Hour() < 10 {
   607  		b = append(b, '0')
   608  	}
   609  
   610  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   611  	b = append(b, pt.timeSeparator...)
   612  
   613  	if t.Minute() < 10 {
   614  		b = append(b, '0')
   615  	}
   616  
   617  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   618  	b = append(b, pt.timeSeparator...)
   619  
   620  	if t.Second() < 10 {
   621  		b = append(b, '0')
   622  	}
   623  
   624  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   625  	b = append(b, []byte{0x20}...)
   626  
   627  	tz, _ := t.Zone()
   628  
   629  	if btz, ok := pt.timezones[tz]; ok {
   630  		b = append(b, btz...)
   631  	} else {
   632  		b = append(b, tz...)
   633  	}
   634  
   635  	return string(b)
   636  }
   637  

View as plain text