...

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

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

     1  package mgo_CM
     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 mgo_CM 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 'mgo_CM' locale
    45  func New() locales.Translator {
    46  	return &mgo_CM{
    47  		locale:                 "mgo_CM",
    48  		pluralsCardinal:        []locales.PluralRule{2, 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{"", "mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"},
    62  		monthsNarrow:           []string{"", "M1", "A2", "M3", "N4", "F5", "I6", "A7", "I8", "K9", "10", "11", "12"},
    63  		monthsWide:             []string{"", "iməg mbegtug", "imeg àbùbì", "imeg mbəŋchubi", "iməg ngwə̀t", "iməg fog", "iməg ichiibɔd", "iməg àdùmbə̀ŋ", "iməg ichika", "iməg kud", "iməg tèsiʼe", "iməg zò", "iməg krizmed"},
    64  		daysAbbreviated:        []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"},
    65  		daysNarrow:             []string{"A1", "A2", "A3", "A4", "A5", "A6", "A7"},
    66  		daysShort:              []string{"1", "2", "3", "4", "5", "6", "7"},
    67  		daysWide:               []string{"Aneg 1", "Aneg 2", "Aneg 3", "Aneg 4", "Aneg 5", "Aneg 6", "Aneg 7"},
    68  		periodsAbbreviated:     []string{"AM", "PM"},
    69  		periodsWide:            []string{"AM", "PM"},
    70  		erasAbbreviated:        []string{"BCE", "CE"},
    71  		erasNarrow:             []string{"", ""},
    72  		erasWide:               []string{"", ""},
    73  		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", "∅∅∅": "∅∅∅"},
    74  	}
    75  }
    76  
    77  // Locale returns the current translators string locale
    78  func (mgo *mgo_CM) Locale() string {
    79  	return mgo.locale
    80  }
    81  
    82  // PluralsCardinal returns the list of cardinal plural rules associated with 'mgo_CM'
    83  func (mgo *mgo_CM) PluralsCardinal() []locales.PluralRule {
    84  	return mgo.pluralsCardinal
    85  }
    86  
    87  // PluralsOrdinal returns the list of ordinal plural rules associated with 'mgo_CM'
    88  func (mgo *mgo_CM) PluralsOrdinal() []locales.PluralRule {
    89  	return mgo.pluralsOrdinal
    90  }
    91  
    92  // PluralsRange returns the list of range plural rules associated with 'mgo_CM'
    93  func (mgo *mgo_CM) PluralsRange() []locales.PluralRule {
    94  	return mgo.pluralsRange
    95  }
    96  
    97  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM'
    98  func (mgo *mgo_CM) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    99  
   100  	n := math.Abs(num)
   101  
   102  	if n == 1 {
   103  		return locales.PluralRuleOne
   104  	}
   105  
   106  	return locales.PluralRuleOther
   107  }
   108  
   109  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'mgo_CM'
   110  func (mgo *mgo_CM) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   111  	return locales.PluralRuleUnknown
   112  }
   113  
   114  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'mgo_CM'
   115  func (mgo *mgo_CM) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   116  	return locales.PluralRuleUnknown
   117  }
   118  
   119  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   120  func (mgo *mgo_CM) MonthAbbreviated(month time.Month) string {
   121  	return mgo.monthsAbbreviated[month]
   122  }
   123  
   124  // MonthsAbbreviated returns the locales abbreviated months
   125  func (mgo *mgo_CM) MonthsAbbreviated() []string {
   126  	return mgo.monthsAbbreviated[1:]
   127  }
   128  
   129  // MonthNarrow returns the locales narrow month given the 'month' provided
   130  func (mgo *mgo_CM) MonthNarrow(month time.Month) string {
   131  	return mgo.monthsNarrow[month]
   132  }
   133  
   134  // MonthsNarrow returns the locales narrow months
   135  func (mgo *mgo_CM) MonthsNarrow() []string {
   136  	return mgo.monthsNarrow[1:]
   137  }
   138  
   139  // MonthWide returns the locales wide month given the 'month' provided
   140  func (mgo *mgo_CM) MonthWide(month time.Month) string {
   141  	return mgo.monthsWide[month]
   142  }
   143  
   144  // MonthsWide returns the locales wide months
   145  func (mgo *mgo_CM) MonthsWide() []string {
   146  	return mgo.monthsWide[1:]
   147  }
   148  
   149  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   150  func (mgo *mgo_CM) WeekdayAbbreviated(weekday time.Weekday) string {
   151  	return mgo.daysAbbreviated[weekday]
   152  }
   153  
   154  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   155  func (mgo *mgo_CM) WeekdaysAbbreviated() []string {
   156  	return mgo.daysAbbreviated
   157  }
   158  
   159  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   160  func (mgo *mgo_CM) WeekdayNarrow(weekday time.Weekday) string {
   161  	return mgo.daysNarrow[weekday]
   162  }
   163  
   164  // WeekdaysNarrow returns the locales narrow weekdays
   165  func (mgo *mgo_CM) WeekdaysNarrow() []string {
   166  	return mgo.daysNarrow
   167  }
   168  
   169  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   170  func (mgo *mgo_CM) WeekdayShort(weekday time.Weekday) string {
   171  	return mgo.daysShort[weekday]
   172  }
   173  
   174  // WeekdaysShort returns the locales short weekdays
   175  func (mgo *mgo_CM) WeekdaysShort() []string {
   176  	return mgo.daysShort
   177  }
   178  
   179  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   180  func (mgo *mgo_CM) WeekdayWide(weekday time.Weekday) string {
   181  	return mgo.daysWide[weekday]
   182  }
   183  
   184  // WeekdaysWide returns the locales wide weekdays
   185  func (mgo *mgo_CM) WeekdaysWide() []string {
   186  	return mgo.daysWide
   187  }
   188  
   189  // Decimal returns the decimal point of number
   190  func (mgo *mgo_CM) Decimal() string {
   191  	return mgo.decimal
   192  }
   193  
   194  // Group returns the group of number
   195  func (mgo *mgo_CM) Group() string {
   196  	return mgo.group
   197  }
   198  
   199  // Group returns the minus sign of number
   200  func (mgo *mgo_CM) Minus() string {
   201  	return mgo.minus
   202  }
   203  
   204  // FmtNumber returns 'num' with digits/precision of 'v' for 'mgo_CM' and handles both Whole and Real numbers based on 'v'
   205  func (mgo *mgo_CM) FmtNumber(num float64, v uint64) string {
   206  
   207  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   208  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   209  	count := 0
   210  	inWhole := v == 0
   211  	b := make([]byte, 0, l)
   212  
   213  	for i := len(s) - 1; i >= 0; i-- {
   214  
   215  		if s[i] == '.' {
   216  			b = append(b, mgo.decimal[0])
   217  			inWhole = true
   218  			continue
   219  		}
   220  
   221  		if inWhole {
   222  			if count == 3 {
   223  				b = append(b, mgo.group[0])
   224  				count = 1
   225  			} else {
   226  				count++
   227  			}
   228  		}
   229  
   230  		b = append(b, s[i])
   231  	}
   232  
   233  	if num < 0 {
   234  		b = append(b, mgo.minus[0])
   235  	}
   236  
   237  	// reverse
   238  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   239  		b[i], b[j] = b[j], b[i]
   240  	}
   241  
   242  	return string(b)
   243  }
   244  
   245  // FmtPercent returns 'num' with digits/precision of 'v' for 'mgo_CM' and handles both Whole and Real numbers based on 'v'
   246  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   247  func (mgo *mgo_CM) FmtPercent(num float64, v uint64) string {
   248  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   249  	l := len(s) + 3
   250  	b := make([]byte, 0, l)
   251  
   252  	for i := len(s) - 1; i >= 0; i-- {
   253  
   254  		if s[i] == '.' {
   255  			b = append(b, mgo.decimal[0])
   256  			continue
   257  		}
   258  
   259  		b = append(b, s[i])
   260  	}
   261  
   262  	if num < 0 {
   263  		b = append(b, mgo.minus[0])
   264  	}
   265  
   266  	// reverse
   267  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   268  		b[i], b[j] = b[j], b[i]
   269  	}
   270  
   271  	b = append(b, mgo.percent...)
   272  
   273  	return string(b)
   274  }
   275  
   276  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'mgo_CM'
   277  func (mgo *mgo_CM) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   278  
   279  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   280  	symbol := mgo.currencies[currency]
   281  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   282  	count := 0
   283  	inWhole := v == 0
   284  	b := make([]byte, 0, l)
   285  
   286  	for i := len(s) - 1; i >= 0; i-- {
   287  
   288  		if s[i] == '.' {
   289  			b = append(b, mgo.decimal[0])
   290  			inWhole = true
   291  			continue
   292  		}
   293  
   294  		if inWhole {
   295  			if count == 3 {
   296  				b = append(b, mgo.group[0])
   297  				count = 1
   298  			} else {
   299  				count++
   300  			}
   301  		}
   302  
   303  		b = append(b, s[i])
   304  	}
   305  
   306  	for j := len(symbol) - 1; j >= 0; j-- {
   307  		b = append(b, symbol[j])
   308  	}
   309  
   310  	for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- {
   311  		b = append(b, mgo.currencyPositivePrefix[j])
   312  	}
   313  
   314  	if num < 0 {
   315  		b = append(b, mgo.minus[0])
   316  	}
   317  
   318  	// reverse
   319  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   320  		b[i], b[j] = b[j], b[i]
   321  	}
   322  
   323  	if int(v) < 2 {
   324  
   325  		if v == 0 {
   326  			b = append(b, mgo.decimal...)
   327  		}
   328  
   329  		for i := 0; i < 2-int(v); i++ {
   330  			b = append(b, '0')
   331  		}
   332  	}
   333  
   334  	return string(b)
   335  }
   336  
   337  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'mgo_CM'
   338  // in accounting notation.
   339  func (mgo *mgo_CM) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   340  
   341  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   342  	symbol := mgo.currencies[currency]
   343  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   344  	count := 0
   345  	inWhole := v == 0
   346  	b := make([]byte, 0, l)
   347  
   348  	for i := len(s) - 1; i >= 0; i-- {
   349  
   350  		if s[i] == '.' {
   351  			b = append(b, mgo.decimal[0])
   352  			inWhole = true
   353  			continue
   354  		}
   355  
   356  		if inWhole {
   357  			if count == 3 {
   358  				b = append(b, mgo.group[0])
   359  				count = 1
   360  			} else {
   361  				count++
   362  			}
   363  		}
   364  
   365  		b = append(b, s[i])
   366  	}
   367  
   368  	if num < 0 {
   369  
   370  		for j := len(symbol) - 1; j >= 0; j-- {
   371  			b = append(b, symbol[j])
   372  		}
   373  
   374  		for j := len(mgo.currencyNegativePrefix) - 1; j >= 0; j-- {
   375  			b = append(b, mgo.currencyNegativePrefix[j])
   376  		}
   377  
   378  		b = append(b, mgo.minus[0])
   379  
   380  	} else {
   381  
   382  		for j := len(symbol) - 1; j >= 0; j-- {
   383  			b = append(b, symbol[j])
   384  		}
   385  
   386  		for j := len(mgo.currencyPositivePrefix) - 1; j >= 0; j-- {
   387  			b = append(b, mgo.currencyPositivePrefix[j])
   388  		}
   389  
   390  	}
   391  
   392  	// reverse
   393  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   394  		b[i], b[j] = b[j], b[i]
   395  	}
   396  
   397  	if int(v) < 2 {
   398  
   399  		if v == 0 {
   400  			b = append(b, mgo.decimal...)
   401  		}
   402  
   403  		for i := 0; i < 2-int(v); i++ {
   404  			b = append(b, '0')
   405  		}
   406  	}
   407  
   408  	return string(b)
   409  }
   410  
   411  // FmtDateShort returns the short date representation of 't' for 'mgo_CM'
   412  func (mgo *mgo_CM) FmtDateShort(t time.Time) string {
   413  
   414  	b := make([]byte, 0, 32)
   415  
   416  	if t.Year() > 0 {
   417  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   418  	} else {
   419  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   420  	}
   421  
   422  	b = append(b, []byte{0x2d}...)
   423  
   424  	if t.Month() < 10 {
   425  		b = append(b, '0')
   426  	}
   427  
   428  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   429  
   430  	b = append(b, []byte{0x2d}...)
   431  
   432  	if t.Day() < 10 {
   433  		b = append(b, '0')
   434  	}
   435  
   436  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   437  
   438  	return string(b)
   439  }
   440  
   441  // FmtDateMedium returns the medium date representation of 't' for 'mgo_CM'
   442  func (mgo *mgo_CM) FmtDateMedium(t time.Time) string {
   443  
   444  	b := make([]byte, 0, 32)
   445  
   446  	if t.Year() > 0 {
   447  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   448  	} else {
   449  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   450  	}
   451  
   452  	b = append(b, []byte{0x20}...)
   453  	b = append(b, mgo.monthsAbbreviated[t.Month()]...)
   454  	b = append(b, []byte{0x20}...)
   455  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   456  
   457  	return string(b)
   458  }
   459  
   460  // FmtDateLong returns the long date representation of 't' for 'mgo_CM'
   461  func (mgo *mgo_CM) FmtDateLong(t time.Time) string {
   462  
   463  	b := make([]byte, 0, 32)
   464  
   465  	if t.Year() > 0 {
   466  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   467  	} else {
   468  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   469  	}
   470  
   471  	b = append(b, []byte{0x20}...)
   472  	b = append(b, mgo.monthsWide[t.Month()]...)
   473  	b = append(b, []byte{0x20}...)
   474  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   475  
   476  	return string(b)
   477  }
   478  
   479  // FmtDateFull returns the full date representation of 't' for 'mgo_CM'
   480  func (mgo *mgo_CM) FmtDateFull(t time.Time) string {
   481  
   482  	b := make([]byte, 0, 32)
   483  
   484  	b = append(b, mgo.daysWide[t.Weekday()]...)
   485  	b = append(b, []byte{0x2c, 0x20}...)
   486  
   487  	if t.Year() > 0 {
   488  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   489  	} else {
   490  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   491  	}
   492  
   493  	b = append(b, []byte{0x20}...)
   494  	b = append(b, mgo.monthsWide[t.Month()]...)
   495  	b = append(b, []byte{0x20}...)
   496  
   497  	if t.Day() < 10 {
   498  		b = append(b, '0')
   499  	}
   500  
   501  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   502  
   503  	return string(b)
   504  }
   505  
   506  // FmtTimeShort returns the short time representation of 't' for 'mgo_CM'
   507  func (mgo *mgo_CM) FmtTimeShort(t time.Time) string {
   508  
   509  	b := make([]byte, 0, 32)
   510  
   511  	if t.Hour() < 10 {
   512  		b = append(b, '0')
   513  	}
   514  
   515  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   516  	b = append(b, mgo.timeSeparator...)
   517  
   518  	if t.Minute() < 10 {
   519  		b = append(b, '0')
   520  	}
   521  
   522  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   523  
   524  	return string(b)
   525  }
   526  
   527  // FmtTimeMedium returns the medium time representation of 't' for 'mgo_CM'
   528  func (mgo *mgo_CM) FmtTimeMedium(t time.Time) string {
   529  
   530  	b := make([]byte, 0, 32)
   531  
   532  	if t.Hour() < 10 {
   533  		b = append(b, '0')
   534  	}
   535  
   536  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   537  	b = append(b, mgo.timeSeparator...)
   538  
   539  	if t.Minute() < 10 {
   540  		b = append(b, '0')
   541  	}
   542  
   543  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   544  	b = append(b, mgo.timeSeparator...)
   545  
   546  	if t.Second() < 10 {
   547  		b = append(b, '0')
   548  	}
   549  
   550  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   551  
   552  	return string(b)
   553  }
   554  
   555  // FmtTimeLong returns the long time representation of 't' for 'mgo_CM'
   556  func (mgo *mgo_CM) FmtTimeLong(t time.Time) string {
   557  
   558  	b := make([]byte, 0, 32)
   559  
   560  	if t.Hour() < 10 {
   561  		b = append(b, '0')
   562  	}
   563  
   564  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   565  	b = append(b, mgo.timeSeparator...)
   566  
   567  	if t.Minute() < 10 {
   568  		b = append(b, '0')
   569  	}
   570  
   571  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   572  	b = append(b, mgo.timeSeparator...)
   573  
   574  	if t.Second() < 10 {
   575  		b = append(b, '0')
   576  	}
   577  
   578  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   579  	b = append(b, []byte{0x20}...)
   580  
   581  	tz, _ := t.Zone()
   582  	b = append(b, tz...)
   583  
   584  	return string(b)
   585  }
   586  
   587  // FmtTimeFull returns the full time representation of 't' for 'mgo_CM'
   588  func (mgo *mgo_CM) FmtTimeFull(t time.Time) string {
   589  
   590  	b := make([]byte, 0, 32)
   591  
   592  	if t.Hour() < 10 {
   593  		b = append(b, '0')
   594  	}
   595  
   596  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   597  	b = append(b, mgo.timeSeparator...)
   598  
   599  	if t.Minute() < 10 {
   600  		b = append(b, '0')
   601  	}
   602  
   603  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   604  	b = append(b, mgo.timeSeparator...)
   605  
   606  	if t.Second() < 10 {
   607  		b = append(b, '0')
   608  	}
   609  
   610  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   611  	b = append(b, []byte{0x20}...)
   612  
   613  	tz, _ := t.Zone()
   614  
   615  	if btz, ok := mgo.timezones[tz]; ok {
   616  		b = append(b, btz...)
   617  	} else {
   618  		b = append(b, tz...)
   619  	}
   620  
   621  	return string(b)
   622  }
   623  

View as plain text