...

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

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

     1  package wo_SN
     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 wo_SN 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  	currencyPositivePrefix string
    26  	currencyNegativePrefix 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 'wo_SN' locale
    45  func New() locales.Translator {
    46  	return &wo_SN{
    47  		locale:                 "wo_SN",
    48  		pluralsCardinal:        []locales.PluralRule{6},
    49  		pluralsOrdinal:         nil,
    50  		pluralsRange:           nil,
    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  		currencyPositivePrefix: " ",
    60  		currencyNegativePrefix: " ",
    61  		monthsAbbreviated:      []string{"", "Sam", "Few", "Mar", "Awr", "Mee", "Suw", "Sul", "Ut", "Sàt", "Okt", "Now", "Des"},
    62  		monthsNarrow:           []string{"", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
    63  		monthsWide:             []string{"", "Samwiyee", "Fewriyee", "Mars", "Awril", "Mee", "Suwe", "Sulet", "Ut", "Sàttumbar", "Oktoobar", "Nowàmbar", "Desàmbar"},
    64  		daysAbbreviated:        []string{"Dib", "Alt", "Tal", "Àla", "Alx", "Àjj", "Ase"},
    65  		daysNarrow:             []string{"Dib", "Alt", "Tal", "Àla", "Alx", "Àjj", "Ase"},
    66  		daysShort:              []string{"Dib", "Alt", "Tal", "Àla", "Alx", "Àjj", "Ase"},
    67  		daysWide:               []string{"Dibéer", "Altine", "Talaata", "Àlarba", "Alxamis", "Àjjuma", "Aseer"},
    68  		periodsAbbreviated:     []string{"Sub", "Ngo"},
    69  		periodsNarrow:          []string{"Sub", "Ngo"},
    70  		periodsWide:            []string{"Sub", "Ngo"},
    71  		erasAbbreviated:        []string{"JC", "AD"},
    72  		erasNarrow:             []string{"", ""},
    73  		erasWide:               []string{"av. JC", "AD"},
    74  		timezones:              map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "ADT (waxtu bëccëgu atlàntik)", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "AST (waxtu estàndaaru penku)", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "CDT (waxtu bëccëgu sàntaraal", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "CST (waxtu estàndaaru sàntaraal)", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "EDT (waxtu bëccëgu penku)", "EST": "EST (waxtu estàndaaru penku)", "GFT": "GFT", "GMT": "GMT (waxtu Greenwich)", "GST": "GST", "GYT": "GYT", "HADT": "HADT", "HAST": "HAST", "HAT": "HAT", "HECU": "HECU", "HEEG": "HEEG", "HENOMX": "HENOMX", "HEOG": "HEOG", "HEPM": "HEPM", "HEPMX": "HEPMX", "HKST": "HKST", "HKT": "HKT", "HNCU": "HNCU", "HNEG": "HNEG", "HNNOMX": "HNNOMX", "HNOG": "HNOG", "HNPM": "HNPM", "HNPMX": "HNPMX", "HNT": "HNT", "IST": "IST", "JDT": "JDT", "JST": "JST", "LHDT": "LHDT", "LHST": "LHST", "MDT": "MDT (waxtu bëccëgu tundu)", "MESZ": "CEST (waxtu ete wu ëroop sàntaraal)", "MEZ": "CEST (waxtu estàndaaru ëroop sàntaraal)", "MST": "MST (waxtu estàndaaru tundu)", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "EEST (waxtu ete wu ëroop u penku)", "OEZ": "EEST (waxtu estàndaaru ëroop u penku)", "PDT": "PDT (waxtu bëccëgu pasifik)", "PST": "PST (waxtu estàndaaru pasifik)", "SAST": "SAST", "SGT": "SGT", "SRT": "SRT", "TMST": "TMST", "TMT": "TMT", "UYST": "UYST", "UYT": "UYT", "VET": "VET", "WARST": "WARST", "WART": "WART", "WAST": "WAST", "WAT": "WAT", "WESZ": "WEST (waxtu ete wu ëroop u sowwu-jant)", "WEZ": "WEST (waxtu estàndaaru ëroop u sowwu-jant)", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (wo *wo_SN) Locale() string {
    80  	return wo.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'wo_SN'
    84  func (wo *wo_SN) PluralsCardinal() []locales.PluralRule {
    85  	return wo.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'wo_SN'
    89  func (wo *wo_SN) PluralsOrdinal() []locales.PluralRule {
    90  	return wo.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'wo_SN'
    94  func (wo *wo_SN) PluralsRange() []locales.PluralRule {
    95  	return wo.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'wo_SN'
    99  func (wo *wo_SN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  	return locales.PluralRuleOther
   101  }
   102  
   103  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'wo_SN'
   104  func (wo *wo_SN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   105  	return locales.PluralRuleUnknown
   106  }
   107  
   108  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'wo_SN'
   109  func (wo *wo_SN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   110  	return locales.PluralRuleUnknown
   111  }
   112  
   113  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   114  func (wo *wo_SN) MonthAbbreviated(month time.Month) string {
   115  	return wo.monthsAbbreviated[month]
   116  }
   117  
   118  // MonthsAbbreviated returns the locales abbreviated months
   119  func (wo *wo_SN) MonthsAbbreviated() []string {
   120  	return wo.monthsAbbreviated[1:]
   121  }
   122  
   123  // MonthNarrow returns the locales narrow month given the 'month' provided
   124  func (wo *wo_SN) MonthNarrow(month time.Month) string {
   125  	return wo.monthsNarrow[month]
   126  }
   127  
   128  // MonthsNarrow returns the locales narrow months
   129  func (wo *wo_SN) MonthsNarrow() []string {
   130  	return wo.monthsNarrow[1:]
   131  }
   132  
   133  // MonthWide returns the locales wide month given the 'month' provided
   134  func (wo *wo_SN) MonthWide(month time.Month) string {
   135  	return wo.monthsWide[month]
   136  }
   137  
   138  // MonthsWide returns the locales wide months
   139  func (wo *wo_SN) MonthsWide() []string {
   140  	return wo.monthsWide[1:]
   141  }
   142  
   143  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   144  func (wo *wo_SN) WeekdayAbbreviated(weekday time.Weekday) string {
   145  	return wo.daysAbbreviated[weekday]
   146  }
   147  
   148  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   149  func (wo *wo_SN) WeekdaysAbbreviated() []string {
   150  	return wo.daysAbbreviated
   151  }
   152  
   153  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   154  func (wo *wo_SN) WeekdayNarrow(weekday time.Weekday) string {
   155  	return wo.daysNarrow[weekday]
   156  }
   157  
   158  // WeekdaysNarrow returns the locales narrow weekdays
   159  func (wo *wo_SN) WeekdaysNarrow() []string {
   160  	return wo.daysNarrow
   161  }
   162  
   163  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   164  func (wo *wo_SN) WeekdayShort(weekday time.Weekday) string {
   165  	return wo.daysShort[weekday]
   166  }
   167  
   168  // WeekdaysShort returns the locales short weekdays
   169  func (wo *wo_SN) WeekdaysShort() []string {
   170  	return wo.daysShort
   171  }
   172  
   173  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   174  func (wo *wo_SN) WeekdayWide(weekday time.Weekday) string {
   175  	return wo.daysWide[weekday]
   176  }
   177  
   178  // WeekdaysWide returns the locales wide weekdays
   179  func (wo *wo_SN) WeekdaysWide() []string {
   180  	return wo.daysWide
   181  }
   182  
   183  // Decimal returns the decimal point of number
   184  func (wo *wo_SN) Decimal() string {
   185  	return wo.decimal
   186  }
   187  
   188  // Group returns the group of number
   189  func (wo *wo_SN) Group() string {
   190  	return wo.group
   191  }
   192  
   193  // Group returns the minus sign of number
   194  func (wo *wo_SN) Minus() string {
   195  	return wo.minus
   196  }
   197  
   198  // FmtNumber returns 'num' with digits/precision of 'v' for 'wo_SN' and handles both Whole and Real numbers based on 'v'
   199  func (wo *wo_SN) FmtNumber(num float64, v uint64) string {
   200  
   201  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   202  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   203  	count := 0
   204  	inWhole := v == 0
   205  	b := make([]byte, 0, l)
   206  
   207  	for i := len(s) - 1; i >= 0; i-- {
   208  
   209  		if s[i] == '.' {
   210  			b = append(b, wo.decimal[0])
   211  			inWhole = true
   212  			continue
   213  		}
   214  
   215  		if inWhole {
   216  			if count == 3 {
   217  				b = append(b, wo.group[0])
   218  				count = 1
   219  			} else {
   220  				count++
   221  			}
   222  		}
   223  
   224  		b = append(b, s[i])
   225  	}
   226  
   227  	if num < 0 {
   228  		b = append(b, wo.minus[0])
   229  	}
   230  
   231  	// reverse
   232  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   233  		b[i], b[j] = b[j], b[i]
   234  	}
   235  
   236  	return string(b)
   237  }
   238  
   239  // FmtPercent returns 'num' with digits/precision of 'v' for 'wo_SN' and handles both Whole and Real numbers based on 'v'
   240  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   241  func (wo *wo_SN) FmtPercent(num float64, v uint64) string {
   242  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   243  	l := len(s) + 3
   244  	b := make([]byte, 0, l)
   245  
   246  	for i := len(s) - 1; i >= 0; i-- {
   247  
   248  		if s[i] == '.' {
   249  			b = append(b, wo.decimal[0])
   250  			continue
   251  		}
   252  
   253  		b = append(b, s[i])
   254  	}
   255  
   256  	if num < 0 {
   257  		b = append(b, wo.minus[0])
   258  	}
   259  
   260  	// reverse
   261  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   262  		b[i], b[j] = b[j], b[i]
   263  	}
   264  
   265  	b = append(b, wo.percent...)
   266  
   267  	return string(b)
   268  }
   269  
   270  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'wo_SN'
   271  func (wo *wo_SN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   272  
   273  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   274  	symbol := wo.currencies[currency]
   275  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   276  	count := 0
   277  	inWhole := v == 0
   278  	b := make([]byte, 0, l)
   279  
   280  	for i := len(s) - 1; i >= 0; i-- {
   281  
   282  		if s[i] == '.' {
   283  			b = append(b, wo.decimal[0])
   284  			inWhole = true
   285  			continue
   286  		}
   287  
   288  		if inWhole {
   289  			if count == 3 {
   290  				b = append(b, wo.group[0])
   291  				count = 1
   292  			} else {
   293  				count++
   294  			}
   295  		}
   296  
   297  		b = append(b, s[i])
   298  	}
   299  
   300  	for j := len(symbol) - 1; j >= 0; j-- {
   301  		b = append(b, symbol[j])
   302  	}
   303  
   304  	for j := len(wo.currencyPositivePrefix) - 1; j >= 0; j-- {
   305  		b = append(b, wo.currencyPositivePrefix[j])
   306  	}
   307  
   308  	if num < 0 {
   309  		b = append(b, wo.minus[0])
   310  	}
   311  
   312  	// reverse
   313  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   314  		b[i], b[j] = b[j], b[i]
   315  	}
   316  
   317  	if int(v) < 2 {
   318  
   319  		if v == 0 {
   320  			b = append(b, wo.decimal...)
   321  		}
   322  
   323  		for i := 0; i < 2-int(v); i++ {
   324  			b = append(b, '0')
   325  		}
   326  	}
   327  
   328  	return string(b)
   329  }
   330  
   331  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'wo_SN'
   332  // in accounting notation.
   333  func (wo *wo_SN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   334  
   335  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   336  	symbol := wo.currencies[currency]
   337  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   338  	count := 0
   339  	inWhole := v == 0
   340  	b := make([]byte, 0, l)
   341  
   342  	for i := len(s) - 1; i >= 0; i-- {
   343  
   344  		if s[i] == '.' {
   345  			b = append(b, wo.decimal[0])
   346  			inWhole = true
   347  			continue
   348  		}
   349  
   350  		if inWhole {
   351  			if count == 3 {
   352  				b = append(b, wo.group[0])
   353  				count = 1
   354  			} else {
   355  				count++
   356  			}
   357  		}
   358  
   359  		b = append(b, s[i])
   360  	}
   361  
   362  	if num < 0 {
   363  
   364  		for j := len(symbol) - 1; j >= 0; j-- {
   365  			b = append(b, symbol[j])
   366  		}
   367  
   368  		for j := len(wo.currencyNegativePrefix) - 1; j >= 0; j-- {
   369  			b = append(b, wo.currencyNegativePrefix[j])
   370  		}
   371  
   372  		b = append(b, wo.minus[0])
   373  
   374  	} else {
   375  
   376  		for j := len(symbol) - 1; j >= 0; j-- {
   377  			b = append(b, symbol[j])
   378  		}
   379  
   380  		for j := len(wo.currencyPositivePrefix) - 1; j >= 0; j-- {
   381  			b = append(b, wo.currencyPositivePrefix[j])
   382  		}
   383  
   384  	}
   385  
   386  	// reverse
   387  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   388  		b[i], b[j] = b[j], b[i]
   389  	}
   390  
   391  	if int(v) < 2 {
   392  
   393  		if v == 0 {
   394  			b = append(b, wo.decimal...)
   395  		}
   396  
   397  		for i := 0; i < 2-int(v); i++ {
   398  			b = append(b, '0')
   399  		}
   400  	}
   401  
   402  	return string(b)
   403  }
   404  
   405  // FmtDateShort returns the short date representation of 't' for 'wo_SN'
   406  func (wo *wo_SN) FmtDateShort(t time.Time) string {
   407  
   408  	b := make([]byte, 0, 32)
   409  
   410  	if t.Day() < 10 {
   411  		b = append(b, '0')
   412  	}
   413  
   414  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   415  	b = append(b, []byte{0x2d}...)
   416  
   417  	if t.Month() < 10 {
   418  		b = append(b, '0')
   419  	}
   420  
   421  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   422  
   423  	b = append(b, []byte{0x2d}...)
   424  
   425  	if t.Year() > 0 {
   426  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   427  	} else {
   428  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   429  	}
   430  
   431  	return string(b)
   432  }
   433  
   434  // FmtDateMedium returns the medium date representation of 't' for 'wo_SN'
   435  func (wo *wo_SN) FmtDateMedium(t time.Time) string {
   436  
   437  	b := make([]byte, 0, 32)
   438  
   439  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   440  	b = append(b, []byte{0x20}...)
   441  	b = append(b, wo.monthsAbbreviated[t.Month()]...)
   442  	b = append(b, []byte{0x2c, 0x20}...)
   443  
   444  	if t.Year() > 0 {
   445  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   446  	} else {
   447  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   448  	}
   449  
   450  	return string(b)
   451  }
   452  
   453  // FmtDateLong returns the long date representation of 't' for 'wo_SN'
   454  func (wo *wo_SN) FmtDateLong(t time.Time) string {
   455  
   456  	b := make([]byte, 0, 32)
   457  
   458  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   459  	b = append(b, []byte{0x20}...)
   460  	b = append(b, wo.monthsWide[t.Month()]...)
   461  	b = append(b, []byte{0x2c, 0x20}...)
   462  
   463  	if t.Year() > 0 {
   464  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   465  	} else {
   466  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   467  	}
   468  
   469  	return string(b)
   470  }
   471  
   472  // FmtDateFull returns the full date representation of 't' for 'wo_SN'
   473  func (wo *wo_SN) FmtDateFull(t time.Time) string {
   474  
   475  	b := make([]byte, 0, 32)
   476  
   477  	b = append(b, wo.daysWide[t.Weekday()]...)
   478  	b = append(b, []byte{0x2c, 0x20}...)
   479  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   480  	b = append(b, []byte{0x20}...)
   481  	b = append(b, wo.monthsAbbreviated[t.Month()]...)
   482  	b = append(b, []byte{0x2c, 0x20}...)
   483  
   484  	if t.Year() > 0 {
   485  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   486  	} else {
   487  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   488  	}
   489  
   490  	return string(b)
   491  }
   492  
   493  // FmtTimeShort returns the short time representation of 't' for 'wo_SN'
   494  func (wo *wo_SN) FmtTimeShort(t time.Time) string {
   495  
   496  	b := make([]byte, 0, 32)
   497  
   498  	if t.Hour() < 10 {
   499  		b = append(b, '0')
   500  	}
   501  
   502  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   503  	b = append(b, wo.timeSeparator...)
   504  
   505  	if t.Minute() < 10 {
   506  		b = append(b, '0')
   507  	}
   508  
   509  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   510  
   511  	return string(b)
   512  }
   513  
   514  // FmtTimeMedium returns the medium time representation of 't' for 'wo_SN'
   515  func (wo *wo_SN) FmtTimeMedium(t time.Time) string {
   516  
   517  	b := make([]byte, 0, 32)
   518  
   519  	if t.Hour() < 10 {
   520  		b = append(b, '0')
   521  	}
   522  
   523  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   524  	b = append(b, wo.timeSeparator...)
   525  
   526  	if t.Minute() < 10 {
   527  		b = append(b, '0')
   528  	}
   529  
   530  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   531  	b = append(b, wo.timeSeparator...)
   532  
   533  	if t.Second() < 10 {
   534  		b = append(b, '0')
   535  	}
   536  
   537  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   538  
   539  	return string(b)
   540  }
   541  
   542  // FmtTimeLong returns the long time representation of 't' for 'wo_SN'
   543  func (wo *wo_SN) FmtTimeLong(t time.Time) string {
   544  
   545  	b := make([]byte, 0, 32)
   546  
   547  	if t.Hour() < 10 {
   548  		b = append(b, '0')
   549  	}
   550  
   551  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   552  	b = append(b, wo.timeSeparator...)
   553  
   554  	if t.Minute() < 10 {
   555  		b = append(b, '0')
   556  	}
   557  
   558  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   559  	b = append(b, wo.timeSeparator...)
   560  
   561  	if t.Second() < 10 {
   562  		b = append(b, '0')
   563  	}
   564  
   565  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   566  	b = append(b, []byte{0x20}...)
   567  
   568  	tz, _ := t.Zone()
   569  	b = append(b, tz...)
   570  
   571  	return string(b)
   572  }
   573  
   574  // FmtTimeFull returns the full time representation of 't' for 'wo_SN'
   575  func (wo *wo_SN) FmtTimeFull(t time.Time) string {
   576  
   577  	b := make([]byte, 0, 32)
   578  
   579  	if t.Hour() < 10 {
   580  		b = append(b, '0')
   581  	}
   582  
   583  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   584  	b = append(b, wo.timeSeparator...)
   585  
   586  	if t.Minute() < 10 {
   587  		b = append(b, '0')
   588  	}
   589  
   590  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   591  	b = append(b, wo.timeSeparator...)
   592  
   593  	if t.Second() < 10 {
   594  		b = append(b, '0')
   595  	}
   596  
   597  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   598  	b = append(b, []byte{0x20}...)
   599  
   600  	tz, _ := t.Zone()
   601  
   602  	if btz, ok := wo.timezones[tz]; ok {
   603  		b = append(b, btz...)
   604  	} else {
   605  		b = append(b, tz...)
   606  	}
   607  
   608  	return string(b)
   609  }
   610  

View as plain text