...

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

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

     1  package bo
     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 bo 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 'bo' locale
    45  func New() locales.Translator {
    46  	return &bo{
    47  		locale:                 "bo",
    48  		pluralsCardinal:        []locales.PluralRule{6},
    49  		pluralsOrdinal:         nil,
    50  		pluralsRange:           nil,
    51  		decimal:                ".",
    52  		group:                  ",",
    53  		timeSeparator:          ":",
    54  		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", "¥", "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"},
    55  		currencyPositivePrefix: " ",
    56  		currencyNegativePrefix: " ",
    57  		monthsAbbreviated:      []string{"", "ཟླ་༡", "ཟླ་༢", "ཟླ་༣", "ཟླ་༤", "ཟླ་༥", "ཟླ་༦", "ཟླ་༧", "ཟླ་༨", "ཟླ་༩", "ཟླ་༡༠", "ཟླ་༡༡", "ཟླ་༡༢"},
    58  		monthsWide:             []string{"", "ཟླ་བ་དང་པོ", "ཟླ་བ་གཉིས་པ", "ཟླ་བ་གསུམ་པ", "ཟླ་བ་བཞི་པ", "ཟླ་བ་ལྔ་པ", "ཟླ་བ་དྲུག་པ", "ཟླ་བ་བདུན་པ", "ཟླ་བ་བརྒྱད་པ", "ཟླ་བ་དགུ་པ", "ཟླ་བ་བཅུ་པ", "ཟླ་བ་བཅུ་གཅིག་པ", "ཟླ་བ་བཅུ་གཉིས་པ"},
    59  		daysAbbreviated:        []string{"ཉི་མ་", "ཟླ་བ་", "མིག་དམར་", "ལྷག་པ་", "ཕུར་བུ་", "པ་སངས་", "སྤེན་པ་"},
    60  		daysNarrow:             []string{"ཉི", "ཟླ", "མིག", "ལྷག", "ཕུར", "སངས", "སྤེན"},
    61  		daysWide:               []string{"གཟའ་ཉི་མ་", "གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་"},
    62  		periodsAbbreviated:     []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"},
    63  		periodsWide:            []string{"སྔ་དྲོ་", "ཕྱི་དྲོ་"},
    64  		erasAbbreviated:        []string{"སྤྱི་ལོ་སྔོན་", "སྤྱི་ལོ་"},
    65  		erasNarrow:             []string{"", ""},
    66  		erasWide:               []string{"", ""},
    67  		timezones:              map[string]string{"ACDT": "ACDT", "ACST": "ACST", "ACWDT": "ACWDT", "ACWST": "ACWST", "ADT": "ADT", "AEDT": "AEDT", "AEST": "AEST", "AKDT": "AKDT", "AKST": "AKST", "ARST": "ARST", "ART": "ART", "AST": "AST", "AWDT": "AWDT", "AWST": "AWST", "BOT": "BOT", "BT": "BT", "CAT": "CAT", "CDT": "CDT", "CHADT": "CHADT", "CHAST": "CHAST", "CLST": "CLST", "CLT": "CLT", "COST": "COST", "COT": "COT", "CST": "CST", "ChST": "ChST", "EAT": "EAT", "ECT": "ECT", "EDT": "EDT", "EST": "EST", "GFT": "GFT", "GMT": "GMT", "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", "MESZ": "MESZ", "MEZ": "MEZ", "MST": "MST", "MYT": "MYT", "NZDT": "NZDT", "NZST": "NZST", "OESZ": "OESZ", "OEZ": "OEZ", "PDT": "PDT", "PST": "PST", "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": "WESZ", "WEZ": "WEZ", "WIB": "WIB", "WIT": "WIT", "WITA": "WITA", "∅∅∅": "∅∅∅"},
    68  	}
    69  }
    70  
    71  // Locale returns the current translators string locale
    72  func (bo *bo) Locale() string {
    73  	return bo.locale
    74  }
    75  
    76  // PluralsCardinal returns the list of cardinal plural rules associated with 'bo'
    77  func (bo *bo) PluralsCardinal() []locales.PluralRule {
    78  	return bo.pluralsCardinal
    79  }
    80  
    81  // PluralsOrdinal returns the list of ordinal plural rules associated with 'bo'
    82  func (bo *bo) PluralsOrdinal() []locales.PluralRule {
    83  	return bo.pluralsOrdinal
    84  }
    85  
    86  // PluralsRange returns the list of range plural rules associated with 'bo'
    87  func (bo *bo) PluralsRange() []locales.PluralRule {
    88  	return bo.pluralsRange
    89  }
    90  
    91  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'bo'
    92  func (bo *bo) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    93  	return locales.PluralRuleOther
    94  }
    95  
    96  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'bo'
    97  func (bo *bo) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
    98  	return locales.PluralRuleUnknown
    99  }
   100  
   101  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'bo'
   102  func (bo *bo) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   103  	return locales.PluralRuleUnknown
   104  }
   105  
   106  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   107  func (bo *bo) MonthAbbreviated(month time.Month) string {
   108  	return bo.monthsAbbreviated[month]
   109  }
   110  
   111  // MonthsAbbreviated returns the locales abbreviated months
   112  func (bo *bo) MonthsAbbreviated() []string {
   113  	return bo.monthsAbbreviated[1:]
   114  }
   115  
   116  // MonthNarrow returns the locales narrow month given the 'month' provided
   117  func (bo *bo) MonthNarrow(month time.Month) string {
   118  	return bo.monthsNarrow[month]
   119  }
   120  
   121  // MonthsNarrow returns the locales narrow months
   122  func (bo *bo) MonthsNarrow() []string {
   123  	return nil
   124  }
   125  
   126  // MonthWide returns the locales wide month given the 'month' provided
   127  func (bo *bo) MonthWide(month time.Month) string {
   128  	return bo.monthsWide[month]
   129  }
   130  
   131  // MonthsWide returns the locales wide months
   132  func (bo *bo) MonthsWide() []string {
   133  	return bo.monthsWide[1:]
   134  }
   135  
   136  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   137  func (bo *bo) WeekdayAbbreviated(weekday time.Weekday) string {
   138  	return bo.daysAbbreviated[weekday]
   139  }
   140  
   141  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   142  func (bo *bo) WeekdaysAbbreviated() []string {
   143  	return bo.daysAbbreviated
   144  }
   145  
   146  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   147  func (bo *bo) WeekdayNarrow(weekday time.Weekday) string {
   148  	return bo.daysNarrow[weekday]
   149  }
   150  
   151  // WeekdaysNarrow returns the locales narrow weekdays
   152  func (bo *bo) WeekdaysNarrow() []string {
   153  	return bo.daysNarrow
   154  }
   155  
   156  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   157  func (bo *bo) WeekdayShort(weekday time.Weekday) string {
   158  	return bo.daysShort[weekday]
   159  }
   160  
   161  // WeekdaysShort returns the locales short weekdays
   162  func (bo *bo) WeekdaysShort() []string {
   163  	return bo.daysShort
   164  }
   165  
   166  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   167  func (bo *bo) WeekdayWide(weekday time.Weekday) string {
   168  	return bo.daysWide[weekday]
   169  }
   170  
   171  // WeekdaysWide returns the locales wide weekdays
   172  func (bo *bo) WeekdaysWide() []string {
   173  	return bo.daysWide
   174  }
   175  
   176  // Decimal returns the decimal point of number
   177  func (bo *bo) Decimal() string {
   178  	return bo.decimal
   179  }
   180  
   181  // Group returns the group of number
   182  func (bo *bo) Group() string {
   183  	return bo.group
   184  }
   185  
   186  // Group returns the minus sign of number
   187  func (bo *bo) Minus() string {
   188  	return bo.minus
   189  }
   190  
   191  // FmtNumber returns 'num' with digits/precision of 'v' for 'bo' and handles both Whole and Real numbers based on 'v'
   192  func (bo *bo) FmtNumber(num float64, v uint64) string {
   193  
   194  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   195  	l := len(s) + 1 + 1*len(s[:len(s)-int(v)-1])/3
   196  	count := 0
   197  	inWhole := v == 0
   198  	b := make([]byte, 0, l)
   199  
   200  	for i := len(s) - 1; i >= 0; i-- {
   201  
   202  		if s[i] == '.' {
   203  			b = append(b, bo.decimal[0])
   204  			inWhole = true
   205  			continue
   206  		}
   207  
   208  		if inWhole {
   209  			if count == 3 {
   210  				b = append(b, bo.group[0])
   211  				count = 1
   212  			} else {
   213  				count++
   214  			}
   215  		}
   216  
   217  		b = append(b, s[i])
   218  	}
   219  
   220  	if num < 0 {
   221  		b = append(b, bo.minus[0])
   222  	}
   223  
   224  	// reverse
   225  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   226  		b[i], b[j] = b[j], b[i]
   227  	}
   228  
   229  	return string(b)
   230  }
   231  
   232  // FmtPercent returns 'num' with digits/precision of 'v' for 'bo' and handles both Whole and Real numbers based on 'v'
   233  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   234  func (bo *bo) FmtPercent(num float64, v uint64) string {
   235  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   236  	l := len(s) + 1
   237  	b := make([]byte, 0, l)
   238  
   239  	for i := len(s) - 1; i >= 0; i-- {
   240  
   241  		if s[i] == '.' {
   242  			b = append(b, bo.decimal[0])
   243  			continue
   244  		}
   245  
   246  		b = append(b, s[i])
   247  	}
   248  
   249  	if num < 0 {
   250  		b = append(b, bo.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  	b = append(b, bo.percent...)
   259  
   260  	return string(b)
   261  }
   262  
   263  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'bo'
   264  func (bo *bo) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   265  
   266  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   267  	symbol := bo.currencies[currency]
   268  	l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3
   269  	count := 0
   270  	inWhole := v == 0
   271  	b := make([]byte, 0, l)
   272  
   273  	for i := len(s) - 1; i >= 0; i-- {
   274  
   275  		if s[i] == '.' {
   276  			b = append(b, bo.decimal[0])
   277  			inWhole = true
   278  			continue
   279  		}
   280  
   281  		if inWhole {
   282  			if count == 3 {
   283  				b = append(b, bo.group[0])
   284  				count = 1
   285  			} else {
   286  				count++
   287  			}
   288  		}
   289  
   290  		b = append(b, s[i])
   291  	}
   292  
   293  	for j := len(symbol) - 1; j >= 0; j-- {
   294  		b = append(b, symbol[j])
   295  	}
   296  
   297  	for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- {
   298  		b = append(b, bo.currencyPositivePrefix[j])
   299  	}
   300  
   301  	if num < 0 {
   302  		b = append(b, bo.minus[0])
   303  	}
   304  
   305  	// reverse
   306  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   307  		b[i], b[j] = b[j], b[i]
   308  	}
   309  
   310  	if int(v) < 2 {
   311  
   312  		if v == 0 {
   313  			b = append(b, bo.decimal...)
   314  		}
   315  
   316  		for i := 0; i < 2-int(v); i++ {
   317  			b = append(b, '0')
   318  		}
   319  	}
   320  
   321  	return string(b)
   322  }
   323  
   324  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'bo'
   325  // in accounting notation.
   326  func (bo *bo) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   327  
   328  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   329  	symbol := bo.currencies[currency]
   330  	l := len(s) + len(symbol) + 3 + 1*len(s[:len(s)-int(v)-1])/3
   331  	count := 0
   332  	inWhole := v == 0
   333  	b := make([]byte, 0, l)
   334  
   335  	for i := len(s) - 1; i >= 0; i-- {
   336  
   337  		if s[i] == '.' {
   338  			b = append(b, bo.decimal[0])
   339  			inWhole = true
   340  			continue
   341  		}
   342  
   343  		if inWhole {
   344  			if count == 3 {
   345  				b = append(b, bo.group[0])
   346  				count = 1
   347  			} else {
   348  				count++
   349  			}
   350  		}
   351  
   352  		b = append(b, s[i])
   353  	}
   354  
   355  	if num < 0 {
   356  
   357  		for j := len(symbol) - 1; j >= 0; j-- {
   358  			b = append(b, symbol[j])
   359  		}
   360  
   361  		for j := len(bo.currencyNegativePrefix) - 1; j >= 0; j-- {
   362  			b = append(b, bo.currencyNegativePrefix[j])
   363  		}
   364  
   365  		b = append(b, bo.minus[0])
   366  
   367  	} else {
   368  
   369  		for j := len(symbol) - 1; j >= 0; j-- {
   370  			b = append(b, symbol[j])
   371  		}
   372  
   373  		for j := len(bo.currencyPositivePrefix) - 1; j >= 0; j-- {
   374  			b = append(b, bo.currencyPositivePrefix[j])
   375  		}
   376  
   377  	}
   378  
   379  	// reverse
   380  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   381  		b[i], b[j] = b[j], b[i]
   382  	}
   383  
   384  	if int(v) < 2 {
   385  
   386  		if v == 0 {
   387  			b = append(b, bo.decimal...)
   388  		}
   389  
   390  		for i := 0; i < 2-int(v); i++ {
   391  			b = append(b, '0')
   392  		}
   393  	}
   394  
   395  	return string(b)
   396  }
   397  
   398  // FmtDateShort returns the short date representation of 't' for 'bo'
   399  func (bo *bo) FmtDateShort(t time.Time) string {
   400  
   401  	b := make([]byte, 0, 32)
   402  
   403  	if t.Year() > 0 {
   404  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   405  	} else {
   406  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   407  	}
   408  
   409  	b = append(b, []byte{0x2d}...)
   410  
   411  	if t.Month() < 10 {
   412  		b = append(b, '0')
   413  	}
   414  
   415  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   416  
   417  	b = append(b, []byte{0x2d}...)
   418  
   419  	if t.Day() < 10 {
   420  		b = append(b, '0')
   421  	}
   422  
   423  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   424  
   425  	return string(b)
   426  }
   427  
   428  // FmtDateMedium returns the medium date representation of 't' for 'bo'
   429  func (bo *bo) FmtDateMedium(t time.Time) string {
   430  
   431  	b := make([]byte, 0, 32)
   432  
   433  	if t.Year() > 0 {
   434  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   435  	} else {
   436  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   437  	}
   438  
   439  	b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b}...)
   440  	b = append(b, bo.monthsAbbreviated[t.Month()]...)
   441  	b = append(b, []byte{0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
   442  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   443  
   444  	return string(b)
   445  }
   446  
   447  // FmtDateLong returns the long date representation of 't' for 'bo'
   448  func (bo *bo) FmtDateLong(t time.Time) string {
   449  
   450  	b := make([]byte, 0, 32)
   451  
   452  	b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...)
   453  
   454  	if t.Year() > 0 {
   455  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   456  	} else {
   457  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   458  	}
   459  
   460  	b = append(b, []byte{0x20}...)
   461  	b = append(b, bo.monthsWide[t.Month()]...)
   462  	b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
   463  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   464  
   465  	return string(b)
   466  }
   467  
   468  // FmtDateFull returns the full date representation of 't' for 'bo'
   469  func (bo *bo) FmtDateFull(t time.Time) string {
   470  
   471  	b := make([]byte, 0, 32)
   472  
   473  	if t.Year() > 0 {
   474  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   475  	} else {
   476  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   477  	}
   478  
   479  	b = append(b, []byte{0x20}...)
   480  	b = append(b, bo.monthsWide[t.Month()]...)
   481  	b = append(b, []byte{0xe0, 0xbd, 0xa0, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
   482  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   483  	b = append(b, []byte{0x2c, 0x20}...)
   484  	b = append(b, bo.daysWide[t.Weekday()]...)
   485  
   486  	return string(b)
   487  }
   488  
   489  // FmtTimeShort returns the short time representation of 't' for 'bo'
   490  func (bo *bo) FmtTimeShort(t time.Time) string {
   491  
   492  	b := make([]byte, 0, 32)
   493  
   494  	h := t.Hour()
   495  
   496  	if h > 12 {
   497  		h -= 12
   498  	}
   499  
   500  	b = strconv.AppendInt(b, int64(h), 10)
   501  	b = append(b, bo.timeSeparator...)
   502  
   503  	if t.Minute() < 10 {
   504  		b = append(b, '0')
   505  	}
   506  
   507  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   508  	b = append(b, []byte{0x20}...)
   509  
   510  	if t.Hour() < 12 {
   511  		b = append(b, bo.periodsAbbreviated[0]...)
   512  	} else {
   513  		b = append(b, bo.periodsAbbreviated[1]...)
   514  	}
   515  
   516  	return string(b)
   517  }
   518  
   519  // FmtTimeMedium returns the medium time representation of 't' for 'bo'
   520  func (bo *bo) FmtTimeMedium(t time.Time) string {
   521  
   522  	b := make([]byte, 0, 32)
   523  
   524  	h := t.Hour()
   525  
   526  	if h > 12 {
   527  		h -= 12
   528  	}
   529  
   530  	b = strconv.AppendInt(b, int64(h), 10)
   531  	b = append(b, bo.timeSeparator...)
   532  
   533  	if t.Minute() < 10 {
   534  		b = append(b, '0')
   535  	}
   536  
   537  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   538  	b = append(b, bo.timeSeparator...)
   539  
   540  	if t.Second() < 10 {
   541  		b = append(b, '0')
   542  	}
   543  
   544  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   545  	b = append(b, []byte{0x20}...)
   546  
   547  	if t.Hour() < 12 {
   548  		b = append(b, bo.periodsAbbreviated[0]...)
   549  	} else {
   550  		b = append(b, bo.periodsAbbreviated[1]...)
   551  	}
   552  
   553  	return string(b)
   554  }
   555  
   556  // FmtTimeLong returns the long time representation of 't' for 'bo'
   557  func (bo *bo) FmtTimeLong(t time.Time) string {
   558  
   559  	b := make([]byte, 0, 32)
   560  
   561  	h := t.Hour()
   562  
   563  	if h > 12 {
   564  		h -= 12
   565  	}
   566  
   567  	b = strconv.AppendInt(b, int64(h), 10)
   568  	b = append(b, bo.timeSeparator...)
   569  
   570  	if t.Minute() < 10 {
   571  		b = append(b, '0')
   572  	}
   573  
   574  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   575  	b = append(b, bo.timeSeparator...)
   576  
   577  	if t.Second() < 10 {
   578  		b = append(b, '0')
   579  	}
   580  
   581  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   582  	b = append(b, []byte{0x20}...)
   583  
   584  	if t.Hour() < 12 {
   585  		b = append(b, bo.periodsAbbreviated[0]...)
   586  	} else {
   587  		b = append(b, bo.periodsAbbreviated[1]...)
   588  	}
   589  
   590  	b = append(b, []byte{0x20}...)
   591  
   592  	tz, _ := t.Zone()
   593  	b = append(b, tz...)
   594  
   595  	return string(b)
   596  }
   597  
   598  // FmtTimeFull returns the full time representation of 't' for 'bo'
   599  func (bo *bo) FmtTimeFull(t time.Time) string {
   600  
   601  	b := make([]byte, 0, 32)
   602  
   603  	h := t.Hour()
   604  
   605  	if h > 12 {
   606  		h -= 12
   607  	}
   608  
   609  	b = strconv.AppendInt(b, int64(h), 10)
   610  	b = append(b, bo.timeSeparator...)
   611  
   612  	if t.Minute() < 10 {
   613  		b = append(b, '0')
   614  	}
   615  
   616  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   617  	b = append(b, bo.timeSeparator...)
   618  
   619  	if t.Second() < 10 {
   620  		b = append(b, '0')
   621  	}
   622  
   623  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   624  	b = append(b, []byte{0x20}...)
   625  
   626  	if t.Hour() < 12 {
   627  		b = append(b, bo.periodsAbbreviated[0]...)
   628  	} else {
   629  		b = append(b, bo.periodsAbbreviated[1]...)
   630  	}
   631  
   632  	b = append(b, []byte{0x20}...)
   633  
   634  	tz, _ := t.Zone()
   635  
   636  	if btz, ok := bo.timezones[tz]; ok {
   637  		b = append(b, btz...)
   638  	} else {
   639  		b = append(b, tz...)
   640  	}
   641  
   642  	return string(b)
   643  }
   644  

View as plain text