...

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

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

     1  package sk
     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 sk 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  	currencyNegativePrefix string
    28  	currencyNegativeSuffix string
    29  	monthsAbbreviated      []string
    30  	monthsNarrow           []string
    31  	monthsWide             []string
    32  	daysAbbreviated        []string
    33  	daysNarrow             []string
    34  	daysShort              []string
    35  	daysWide               []string
    36  	periodsAbbreviated     []string
    37  	periodsNarrow          []string
    38  	periodsShort           []string
    39  	periodsWide            []string
    40  	erasAbbreviated        []string
    41  	erasNarrow             []string
    42  	erasWide               []string
    43  	timezones              map[string]string
    44  }
    45  
    46  // New returns a new instance of translator for the 'sk' locale
    47  func New() locales.Translator {
    48  	return &sk{
    49  		locale:                 "sk",
    50  		pluralsCardinal:        []locales.PluralRule{2, 4, 5, 6},
    51  		pluralsOrdinal:         []locales.PluralRule{6},
    52  		pluralsRange:           []locales.PluralRule{2, 4, 5, 6},
    53  		decimal:                ",",
    54  		group:                  " ",
    55  		minus:                  "-",
    56  		percent:                "%",
    57  		perMille:               "‰",
    58  		timeSeparator:          ":",
    59  		inifinity:              "∞",
    60  		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", "€", "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", "NIS", "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", "MX$", "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", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
    61  		percentSuffix:          " ",
    62  		currencyPositiveSuffix: " ",
    63  		currencyNegativePrefix: "(",
    64  		currencyNegativeSuffix: " )",
    65  		monthsAbbreviated:      []string{"", "jan", "feb", "mar", "apr", "máj", "jún", "júl", "aug", "sep", "okt", "nov", "dec"},
    66  		monthsNarrow:           []string{"", "j", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"},
    67  		monthsWide:             []string{"", "januára", "februára", "marca", "apríla", "mája", "júna", "júla", "augusta", "septembra", "októbra", "novembra", "decembra"},
    68  		daysAbbreviated:        []string{"ne", "po", "ut", "st", "št", "pi", "so"},
    69  		daysNarrow:             []string{"n", "p", "u", "s", "š", "p", "s"},
    70  		daysShort:              []string{"ne", "po", "ut", "st", "št", "pi", "so"},
    71  		daysWide:               []string{"nedeľa", "pondelok", "utorok", "streda", "štvrtok", "piatok", "sobota"},
    72  		periodsAbbreviated:     []string{"AM", "PM"},
    73  		periodsNarrow:          []string{"AM", "PM"},
    74  		periodsWide:            []string{"AM", "PM"},
    75  		erasAbbreviated:        []string{"pred Kr.", "po Kr."},
    76  		erasNarrow:             []string{"", ""},
    77  		erasWide:               []string{"pred Kristom", "po Kristovi"},
    78  		timezones:              map[string]string{"ACDT": "stredoaustrálsky letný čas", "ACST": "stredoaustrálsky štandardný čas", "ACWDT": "stredozápadný austrálsky letný čas", "ACWST": "stredozápadný austrálsky štandardný čas", "ADT": "atlantický letný čas", "AEDT": "východoaustrálsky letný čas", "AEST": "východoaustrálsky štandardný čas", "AKDT": "aljašský letný čas", "AKST": "aljašský štandardný čas", "ARST": "argentínsky letný čas", "ART": "argentínsky štandardný čas", "AST": "atlantický štandardný čas", "AWDT": "západoaustrálsky letný čas", "AWST": "západoaustrálsky štandardný čas", "BOT": "bolívijský čas", "BT": "bhutánsky čas", "CAT": "stredoafrický čas", "CDT": "severoamerický centrálny letný čas", "CHADT": "chathamský letný čas", "CHAST": "chathamský štandardný čas", "CLST": "čilský letný čas", "CLT": "čilský štandardný čas", "COST": "kolumbijský letný čas", "COT": "kolumbijský štandardný čas", "CST": "severoamerický centrálny štandardný čas", "ChST": "chamorrský čas", "EAT": "východoafrický čas", "ECT": "ekvádorský čas", "EDT": "severoamerický východný letný čas", "EST": "severoamerický východný štandardný čas", "GFT": "francúzskoguyanský čas", "GMT": "greenwichský čas", "GST": "štandardný čas Perzského zálivu", "GYT": "guyanský čas", "HADT": "havajsko-aleutský letný čas", "HAST": "havajsko-aleutský štandardný čas", "HAT": "newfoundlandský letný čas", "HECU": "kubánsky letný čas", "HEEG": "východogrónsky letný čas", "HENOMX": "severozápadný mexický letný čas", "HEOG": "západogrónsky letný čas", "HEPM": "pierre-miquelonský letný čas", "HEPMX": "mexický tichomorský letný čas", "HKST": "hongkonský letný čas", "HKT": "hongkonský štandardný čas", "HNCU": "kubánsky štandardný čas", "HNEG": "východogrónsky štandardný čas", "HNNOMX": "severozápadný mexický štandardný čas", "HNOG": "západogrónsky štandardný čas", "HNPM": "pierre-miquelonský štandardný čas", "HNPMX": "mexický tichomorský štandardný čas", "HNT": "newfoundlandský štandardný čas", "IST": "indický čas", "JDT": "japonský letný čas", "JST": "japonský štandardný čas", "LHDT": "letný čas ostrova lorda Howa", "LHST": "štandardný čas ostrova lorda Howa", "MDT": "severoamerický horský letný čas", "MESZ": "stredoeurópsky letný čas", "MEZ": "stredoeurópsky štandardný čas", "MST": "severoamerický horský štandardný čas", "MYT": "malajzijský čas", "NZDT": "novozélandský letný čas", "NZST": "novozélandský štandardný čas", "OESZ": "východoeurópsky letný čas", "OEZ": "východoeurópsky štandardný čas", "PDT": "severoamerický tichomorský letný čas", "PST": "severoamerický tichomorský štandardný čas", "SAST": "juhoafrický čas", "SGT": "singapurský štandardný čas", "SRT": "surinamský čas", "TMST": "turkménsky letný čas", "TMT": "turkménsky štandardný čas", "UYST": "uruguajský letný čas", "UYT": "uruguajský štandardný čas", "VET": "venezuelský čas", "WARST": "západoargentínsky letný čas", "WART": "západoargentínsky štandardný čas", "WAST": "západoafrický letný čas", "WAT": "západoafrický štandardný čas", "WESZ": "západoeurópsky letný čas", "WEZ": "západoeurópsky štandardný čas", "WIB": "západoindonézsky čas", "WIT": "východoindonézsky čas", "WITA": "stredoindonézsky čas", "∅∅∅": "brazílsky letný čas"},
    79  	}
    80  }
    81  
    82  // Locale returns the current translators string locale
    83  func (sk *sk) Locale() string {
    84  	return sk.locale
    85  }
    86  
    87  // PluralsCardinal returns the list of cardinal plural rules associated with 'sk'
    88  func (sk *sk) PluralsCardinal() []locales.PluralRule {
    89  	return sk.pluralsCardinal
    90  }
    91  
    92  // PluralsOrdinal returns the list of ordinal plural rules associated with 'sk'
    93  func (sk *sk) PluralsOrdinal() []locales.PluralRule {
    94  	return sk.pluralsOrdinal
    95  }
    96  
    97  // PluralsRange returns the list of range plural rules associated with 'sk'
    98  func (sk *sk) PluralsRange() []locales.PluralRule {
    99  	return sk.pluralsRange
   100  }
   101  
   102  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'sk'
   103  func (sk *sk) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   104  
   105  	n := math.Abs(num)
   106  	i := int64(n)
   107  
   108  	if i == 1 && v == 0 {
   109  		return locales.PluralRuleOne
   110  	} else if i >= 2 && i <= 4 && v == 0 {
   111  		return locales.PluralRuleFew
   112  	} else if v != 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 'sk'
   120  func (sk *sk) 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 'sk'
   125  func (sk *sk) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   126  
   127  	start := sk.CardinalPluralRule(num1, v1)
   128  	end := sk.CardinalPluralRule(num2, v2)
   129  
   130  	if start == locales.PluralRuleOne && end == locales.PluralRuleFew {
   131  		return locales.PluralRuleFew
   132  	} else if start == locales.PluralRuleOne && end == locales.PluralRuleMany {
   133  		return locales.PluralRuleMany
   134  	} else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
   135  		return locales.PluralRuleOther
   136  	} else if start == locales.PluralRuleFew && end == locales.PluralRuleFew {
   137  		return locales.PluralRuleFew
   138  	} else if start == locales.PluralRuleFew && end == locales.PluralRuleMany {
   139  		return locales.PluralRuleMany
   140  	} else if start == locales.PluralRuleFew && end == locales.PluralRuleOther {
   141  		return locales.PluralRuleOther
   142  	} else if start == locales.PluralRuleMany && end == locales.PluralRuleOne {
   143  		return locales.PluralRuleOne
   144  	} else if start == locales.PluralRuleMany && end == locales.PluralRuleFew {
   145  		return locales.PluralRuleFew
   146  	} else if start == locales.PluralRuleMany && end == locales.PluralRuleMany {
   147  		return locales.PluralRuleMany
   148  	} else if start == locales.PluralRuleMany && end == locales.PluralRuleOther {
   149  		return locales.PluralRuleOther
   150  	} else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
   151  		return locales.PluralRuleOne
   152  	} else if start == locales.PluralRuleOther && end == locales.PluralRuleFew {
   153  		return locales.PluralRuleFew
   154  	} else if start == locales.PluralRuleOther && end == locales.PluralRuleMany {
   155  		return locales.PluralRuleMany
   156  	}
   157  
   158  	return locales.PluralRuleOther
   159  
   160  }
   161  
   162  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   163  func (sk *sk) MonthAbbreviated(month time.Month) string {
   164  	return sk.monthsAbbreviated[month]
   165  }
   166  
   167  // MonthsAbbreviated returns the locales abbreviated months
   168  func (sk *sk) MonthsAbbreviated() []string {
   169  	return sk.monthsAbbreviated[1:]
   170  }
   171  
   172  // MonthNarrow returns the locales narrow month given the 'month' provided
   173  func (sk *sk) MonthNarrow(month time.Month) string {
   174  	return sk.monthsNarrow[month]
   175  }
   176  
   177  // MonthsNarrow returns the locales narrow months
   178  func (sk *sk) MonthsNarrow() []string {
   179  	return sk.monthsNarrow[1:]
   180  }
   181  
   182  // MonthWide returns the locales wide month given the 'month' provided
   183  func (sk *sk) MonthWide(month time.Month) string {
   184  	return sk.monthsWide[month]
   185  }
   186  
   187  // MonthsWide returns the locales wide months
   188  func (sk *sk) MonthsWide() []string {
   189  	return sk.monthsWide[1:]
   190  }
   191  
   192  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   193  func (sk *sk) WeekdayAbbreviated(weekday time.Weekday) string {
   194  	return sk.daysAbbreviated[weekday]
   195  }
   196  
   197  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   198  func (sk *sk) WeekdaysAbbreviated() []string {
   199  	return sk.daysAbbreviated
   200  }
   201  
   202  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   203  func (sk *sk) WeekdayNarrow(weekday time.Weekday) string {
   204  	return sk.daysNarrow[weekday]
   205  }
   206  
   207  // WeekdaysNarrow returns the locales narrow weekdays
   208  func (sk *sk) WeekdaysNarrow() []string {
   209  	return sk.daysNarrow
   210  }
   211  
   212  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   213  func (sk *sk) WeekdayShort(weekday time.Weekday) string {
   214  	return sk.daysShort[weekday]
   215  }
   216  
   217  // WeekdaysShort returns the locales short weekdays
   218  func (sk *sk) WeekdaysShort() []string {
   219  	return sk.daysShort
   220  }
   221  
   222  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   223  func (sk *sk) WeekdayWide(weekday time.Weekday) string {
   224  	return sk.daysWide[weekday]
   225  }
   226  
   227  // WeekdaysWide returns the locales wide weekdays
   228  func (sk *sk) WeekdaysWide() []string {
   229  	return sk.daysWide
   230  }
   231  
   232  // Decimal returns the decimal point of number
   233  func (sk *sk) Decimal() string {
   234  	return sk.decimal
   235  }
   236  
   237  // Group returns the group of number
   238  func (sk *sk) Group() string {
   239  	return sk.group
   240  }
   241  
   242  // Group returns the minus sign of number
   243  func (sk *sk) Minus() string {
   244  	return sk.minus
   245  }
   246  
   247  // FmtNumber returns 'num' with digits/precision of 'v' for 'sk' and handles both Whole and Real numbers based on 'v'
   248  func (sk *sk) FmtNumber(num float64, v uint64) string {
   249  
   250  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   251  	l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
   252  	count := 0
   253  	inWhole := v == 0
   254  	b := make([]byte, 0, l)
   255  
   256  	for i := len(s) - 1; i >= 0; i-- {
   257  
   258  		if s[i] == '.' {
   259  			b = append(b, sk.decimal[0])
   260  			inWhole = true
   261  			continue
   262  		}
   263  
   264  		if inWhole {
   265  			if count == 3 {
   266  				for j := len(sk.group) - 1; j >= 0; j-- {
   267  					b = append(b, sk.group[j])
   268  				}
   269  				count = 1
   270  			} else {
   271  				count++
   272  			}
   273  		}
   274  
   275  		b = append(b, s[i])
   276  	}
   277  
   278  	if num < 0 {
   279  		b = append(b, sk.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  	return string(b)
   288  }
   289  
   290  // FmtPercent returns 'num' with digits/precision of 'v' for 'sk' and handles both Whole and Real numbers based on 'v'
   291  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   292  func (sk *sk) FmtPercent(num float64, v uint64) string {
   293  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   294  	l := len(s) + 5
   295  	b := make([]byte, 0, l)
   296  
   297  	for i := len(s) - 1; i >= 0; i-- {
   298  
   299  		if s[i] == '.' {
   300  			b = append(b, sk.decimal[0])
   301  			continue
   302  		}
   303  
   304  		b = append(b, s[i])
   305  	}
   306  
   307  	if num < 0 {
   308  		b = append(b, sk.minus[0])
   309  	}
   310  
   311  	// reverse
   312  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   313  		b[i], b[j] = b[j], b[i]
   314  	}
   315  
   316  	b = append(b, sk.percentSuffix...)
   317  
   318  	b = append(b, sk.percent...)
   319  
   320  	return string(b)
   321  }
   322  
   323  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'sk'
   324  func (sk *sk) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   325  
   326  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   327  	symbol := sk.currencies[currency]
   328  	l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
   329  	count := 0
   330  	inWhole := v == 0
   331  	b := make([]byte, 0, l)
   332  
   333  	for i := len(s) - 1; i >= 0; i-- {
   334  
   335  		if s[i] == '.' {
   336  			b = append(b, sk.decimal[0])
   337  			inWhole = true
   338  			continue
   339  		}
   340  
   341  		if inWhole {
   342  			if count == 3 {
   343  				for j := len(sk.group) - 1; j >= 0; j-- {
   344  					b = append(b, sk.group[j])
   345  				}
   346  				count = 1
   347  			} else {
   348  				count++
   349  			}
   350  		}
   351  
   352  		b = append(b, s[i])
   353  	}
   354  
   355  	if num < 0 {
   356  		b = append(b, sk.minus[0])
   357  	}
   358  
   359  	// reverse
   360  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   361  		b[i], b[j] = b[j], b[i]
   362  	}
   363  
   364  	if int(v) < 2 {
   365  
   366  		if v == 0 {
   367  			b = append(b, sk.decimal...)
   368  		}
   369  
   370  		for i := 0; i < 2-int(v); i++ {
   371  			b = append(b, '0')
   372  		}
   373  	}
   374  
   375  	b = append(b, sk.currencyPositiveSuffix...)
   376  
   377  	b = append(b, symbol...)
   378  
   379  	return string(b)
   380  }
   381  
   382  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'sk'
   383  // in accounting notation.
   384  func (sk *sk) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   385  
   386  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   387  	symbol := sk.currencies[currency]
   388  	l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
   389  	count := 0
   390  	inWhole := v == 0
   391  	b := make([]byte, 0, l)
   392  
   393  	for i := len(s) - 1; i >= 0; i-- {
   394  
   395  		if s[i] == '.' {
   396  			b = append(b, sk.decimal[0])
   397  			inWhole = true
   398  			continue
   399  		}
   400  
   401  		if inWhole {
   402  			if count == 3 {
   403  				for j := len(sk.group) - 1; j >= 0; j-- {
   404  					b = append(b, sk.group[j])
   405  				}
   406  				count = 1
   407  			} else {
   408  				count++
   409  			}
   410  		}
   411  
   412  		b = append(b, s[i])
   413  	}
   414  
   415  	if num < 0 {
   416  
   417  		b = append(b, sk.currencyNegativePrefix[0])
   418  
   419  	}
   420  
   421  	// reverse
   422  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   423  		b[i], b[j] = b[j], b[i]
   424  	}
   425  
   426  	if int(v) < 2 {
   427  
   428  		if v == 0 {
   429  			b = append(b, sk.decimal...)
   430  		}
   431  
   432  		for i := 0; i < 2-int(v); i++ {
   433  			b = append(b, '0')
   434  		}
   435  	}
   436  
   437  	if num < 0 {
   438  		b = append(b, sk.currencyNegativeSuffix...)
   439  		b = append(b, symbol...)
   440  	} else {
   441  
   442  		b = append(b, sk.currencyPositiveSuffix...)
   443  		b = append(b, symbol...)
   444  	}
   445  
   446  	return string(b)
   447  }
   448  
   449  // FmtDateShort returns the short date representation of 't' for 'sk'
   450  func (sk *sk) FmtDateShort(t time.Time) string {
   451  
   452  	b := make([]byte, 0, 32)
   453  
   454  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   455  	b = append(b, []byte{0x2e, 0x20}...)
   456  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   457  	b = append(b, []byte{0x2e, 0x20}...)
   458  
   459  	if t.Year() > 0 {
   460  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   461  	} else {
   462  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   463  	}
   464  
   465  	return string(b)
   466  }
   467  
   468  // FmtDateMedium returns the medium date representation of 't' for 'sk'
   469  func (sk *sk) FmtDateMedium(t time.Time) string {
   470  
   471  	b := make([]byte, 0, 32)
   472  
   473  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   474  	b = append(b, []byte{0x2e, 0x20}...)
   475  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   476  	b = append(b, []byte{0x2e, 0x20}...)
   477  
   478  	if t.Year() > 0 {
   479  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   480  	} else {
   481  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   482  	}
   483  
   484  	return string(b)
   485  }
   486  
   487  // FmtDateLong returns the long date representation of 't' for 'sk'
   488  func (sk *sk) FmtDateLong(t time.Time) string {
   489  
   490  	b := make([]byte, 0, 32)
   491  
   492  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   493  	b = append(b, []byte{0x2e, 0x20}...)
   494  	b = append(b, sk.monthsWide[t.Month()]...)
   495  	b = append(b, []byte{0x20}...)
   496  
   497  	if t.Year() > 0 {
   498  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   499  	} else {
   500  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   501  	}
   502  
   503  	return string(b)
   504  }
   505  
   506  // FmtDateFull returns the full date representation of 't' for 'sk'
   507  func (sk *sk) FmtDateFull(t time.Time) string {
   508  
   509  	b := make([]byte, 0, 32)
   510  
   511  	b = append(b, sk.daysWide[t.Weekday()]...)
   512  	b = append(b, []byte{0x20}...)
   513  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   514  	b = append(b, []byte{0x2e, 0x20}...)
   515  	b = append(b, sk.monthsWide[t.Month()]...)
   516  	b = append(b, []byte{0x20}...)
   517  
   518  	if t.Year() > 0 {
   519  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   520  	} else {
   521  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   522  	}
   523  
   524  	return string(b)
   525  }
   526  
   527  // FmtTimeShort returns the short time representation of 't' for 'sk'
   528  func (sk *sk) FmtTimeShort(t time.Time) string {
   529  
   530  	b := make([]byte, 0, 32)
   531  
   532  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   533  	b = append(b, sk.timeSeparator...)
   534  
   535  	if t.Minute() < 10 {
   536  		b = append(b, '0')
   537  	}
   538  
   539  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   540  
   541  	return string(b)
   542  }
   543  
   544  // FmtTimeMedium returns the medium time representation of 't' for 'sk'
   545  func (sk *sk) FmtTimeMedium(t time.Time) string {
   546  
   547  	b := make([]byte, 0, 32)
   548  
   549  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   550  	b = append(b, sk.timeSeparator...)
   551  
   552  	if t.Minute() < 10 {
   553  		b = append(b, '0')
   554  	}
   555  
   556  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   557  	b = append(b, sk.timeSeparator...)
   558  
   559  	if t.Second() < 10 {
   560  		b = append(b, '0')
   561  	}
   562  
   563  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   564  
   565  	return string(b)
   566  }
   567  
   568  // FmtTimeLong returns the long time representation of 't' for 'sk'
   569  func (sk *sk) FmtTimeLong(t time.Time) string {
   570  
   571  	b := make([]byte, 0, 32)
   572  
   573  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   574  	b = append(b, sk.timeSeparator...)
   575  
   576  	if t.Minute() < 10 {
   577  		b = append(b, '0')
   578  	}
   579  
   580  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   581  	b = append(b, sk.timeSeparator...)
   582  
   583  	if t.Second() < 10 {
   584  		b = append(b, '0')
   585  	}
   586  
   587  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   588  	b = append(b, []byte{0x20}...)
   589  
   590  	tz, _ := t.Zone()
   591  	b = append(b, tz...)
   592  
   593  	return string(b)
   594  }
   595  
   596  // FmtTimeFull returns the full time representation of 't' for 'sk'
   597  func (sk *sk) FmtTimeFull(t time.Time) string {
   598  
   599  	b := make([]byte, 0, 32)
   600  
   601  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   602  	b = append(b, sk.timeSeparator...)
   603  
   604  	if t.Minute() < 10 {
   605  		b = append(b, '0')
   606  	}
   607  
   608  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   609  	b = append(b, sk.timeSeparator...)
   610  
   611  	if t.Second() < 10 {
   612  		b = append(b, '0')
   613  	}
   614  
   615  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   616  	b = append(b, []byte{0x20}...)
   617  
   618  	tz, _ := t.Zone()
   619  
   620  	if btz, ok := sk.timezones[tz]; ok {
   621  		b = append(b, btz...)
   622  	} else {
   623  		b = append(b, tz...)
   624  	}
   625  
   626  	return string(b)
   627  }
   628  

View as plain text