...

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

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

     1  package gd_GB
     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 gd_GB 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  	currencyNegativePrefix string
    26  	currencyNegativeSuffix 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 'gd_GB' locale
    45  func New() locales.Translator {
    46  	return &gd_GB{
    47  		locale:                 "gd_GB",
    48  		pluralsCardinal:        []locales.PluralRule{2, 3, 4, 6},
    49  		pluralsOrdinal:         []locales.PluralRule{2, 3, 4, 6},
    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  		currencyNegativePrefix: "(",
    60  		currencyNegativeSuffix: ")",
    61  		monthsAbbreviated:      []string{"", "Faoi", "Gearr", "Màrt", "Gibl", "Cèit", "Ògmh", "Iuch", "Lùna", "Sult", "Dàmh", "Samh", "Dùbh"},
    62  		monthsNarrow:           []string{"", "F", "G", "M", "G", "C", "Ò", "I", "L", "S", "D", "S", "D"},
    63  		monthsWide:             []string{"", "dhen Fhaoilleach", "dhen Ghearran", "dhen Mhàrt", "dhen Ghiblean", "dhen Chèitean", "dhen Ògmhios", "dhen Iuchar", "dhen Lùnastal", "dhen t-Sultain", "dhen Dàmhair", "dhen t-Samhain", "dhen Dùbhlachd"},
    64  		daysAbbreviated:        []string{"DiD", "DiL", "DiM", "DiC", "Dia", "Dih", "DiS"},
    65  		daysNarrow:             []string{"D", "L", "M", "C", "A", "H", "S"},
    66  		daysShort:              []string{"Dò", "Lu", "Mà", "Ci", "Da", "hA", "Sa"},
    67  		daysWide:               []string{"DiDòmhnaich", "DiLuain", "DiMàirt", "DiCiadain", "DiarDaoin", "DihAoine", "DiSathairne"},
    68  		periodsAbbreviated:     []string{"m", "f"},
    69  		periodsNarrow:          []string{"m", "f"},
    70  		periodsWide:            []string{"m", "f"},
    71  		erasAbbreviated:        []string{"RC", "AD"},
    72  		erasNarrow:             []string{"R", "A"},
    73  		erasWide:               []string{"Ro Chrìosta", "An dèidh Chrìosta"},
    74  		timezones:              map[string]string{"ACDT": "Tìde samhraidh Meadhan Astràilia", "ACST": "Bun-àm Meadhan Astràilia", "ACWDT": "Tìde samhraidh Meadhan Astràilia an Iar", "ACWST": "Bun-àm Meadhan Astràilia an Iar", "ADT": "Tìde samhraidh a’ Chuain Siar", "AEDT": "Tìde samhraidh Astràilia an Ear", "AEST": "Bun-àm Astràilia an Ear", "AKDT": "Tìde samhraidh Alaska", "AKST": "Bun-àm Alaska", "ARST": "Tìde samhraidh na h-Argantaine", "ART": "Bun-àm na h-Argantaine", "AST": "Bun-àm a’ Chuain Siar", "AWDT": "Tìde samhraidh Astràilia an Iar", "AWST": "Bun-àm Astràilia an Iar", "BOT": "Àm Boilibhia", "BT": "Àm Butàin", "CAT": "Àm Meadhan Afraga", "CDT": "Tìde samhraidh Meadhan Aimeireaga a Tuath", "CHADT": "Tìde samhraidh Chatham", "CHAST": "Bun-àm Chatham", "CLST": "Tìde samhraidh na Sile", "CLT": "Bun-àm na Sile", "COST": "Tìde samhraidh Coloimbia", "COT": "Bun-àm Coloimbia", "CST": "Bun-àm Meadhan Aimeireaga a Tuath", "ChST": "Àm Chamorro", "EAT": "Àm Afraga an Ear", "ECT": "Àm Eacuadoir", "EDT": "Tìde samhraidh Aimeireaga a Tuath an Ear", "EST": "Bun-àm Aimeireaga a Tuath an Ear", "GFT": "Àm Guidheàna na Frainge", "GMT": "Greenwich Mean Time", "GST": "Àm a’ Chamais", "GYT": "Àm Guidheàna", "HADT": "Tìde Samhraidh nan Eileanan Hawai’i ’s Aleutach", "HAST": "Bun-àm nan Eileanan Hawai’i ’s Aleutach", "HAT": "Tìde samhraidh Talamh an Èisg", "HECU": "Tìde samhraidh Cùba", "HEEG": "Tìde samhraidh na Graonlainn an Ear", "HENOMX": "Tìde samhraidh Mheagsago an Iar-thuath", "HEOG": "Tìde samhraidh na Graonlainn an Iar", "HEPM": "Tìde Samhraidh Saint Pierre agus Miquelon", "HEPMX": "Tìde samhraidh a’ Chuain Sèimh Mheagsago", "HKST": "Tìde samhraidh Hong Kong", "HKT": "Bun-àm Hong Kong", "HNCU": "Bun-àm Cùba", "HNEG": "Bun-àm na Graonlainn an Ear", "HNNOMX": "Bun-àm Mheagsago an Iar-thuath", "HNOG": "Bun-àm na Graonlainn an Iar", "HNPM": "Bun-àm Saint Pierre agus Miquelon", "HNPMX": "Bun-àm a’ Chuain Sèimh Mheagsago", "HNT": "Bun-àm Talamh an Èisg", "IST": "Àm nan Innseachan", "JDT": "Tìde samhraidh na Seapaine", "JST": "Bun-àm na Seapaine", "LHDT": "Tìde samhraidh Lord Howe", "LHST": "Bun-àm Lord Howe", "MDT": "Tìde samhraidh Monadh Aimeireaga a Tuath", "MESZ": "Tìde samhraidh Meadhan na Roinn-Eòrpa", "MEZ": "Bun-àm Meadhan na Roinn-Eòrpa", "MST": "Bun-àm Monadh Aimeireaga a Tuath", "MYT": "Àm Mhalaidhsea", "NZDT": "Tìde samhraidh Shealainn Nuaidh", "NZST": "Bun-àm Shealainn Nuaidh", "OESZ": "Tìde samhraidh na Roinn-Eòrpa an Ear", "OEZ": "Bun-àm na Roinn-Eòrpa an Ear", "PDT": "Tìde samhraidh a’ Chuain Sèimh", "PST": "Bun-àm a’ Chuain Sèimh", "SAST": "Àm Afraga a Deas", "SGT": "Àm Singeapòr", "SRT": "Àm Suranaim", "TMST": "Tìde samhraidh Turcmanastàin", "TMT": "Bun-àm Turcmanastàin", "UYST": "Tìde samhraidh Uruguaidh", "UYT": "Bun-àm Uruguaidh", "VET": "Àm na Bheiniseala", "WARST": "Tìde samhraidh na h-Argantaine Siaraich", "WART": "Bun-àm na h-Argantaine Siaraich", "WAST": "Tìde Samhraidh Afraga an Iar", "WAT": "Bun-àm Afraga an Iar", "WESZ": "Tìde samhraidh na Roinn-Eòrpa an Iar", "WEZ": "Bun-àm na Roinn-Eòrpa an Iar", "WIB": "Àm nan Innd-Innse an Iar", "WIT": "Àm nan Innd-Innse an Ear", "WITA": "Àm Meadhan nan Innd-Innse", "∅∅∅": "Tìde samhraidh Bhrasilia"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (gd *gd_GB) Locale() string {
    80  	return gd.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'gd_GB'
    84  func (gd *gd_GB) PluralsCardinal() []locales.PluralRule {
    85  	return gd.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'gd_GB'
    89  func (gd *gd_GB) PluralsOrdinal() []locales.PluralRule {
    90  	return gd.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'gd_GB'
    94  func (gd *gd_GB) PluralsRange() []locales.PluralRule {
    95  	return gd.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'gd_GB'
    99  func (gd *gd_GB) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  
   101  	n := math.Abs(num)
   102  
   103  	if n == 1 || n == 11 {
   104  		return locales.PluralRuleOne
   105  	} else if n == 2 || n == 12 {
   106  		return locales.PluralRuleTwo
   107  	} else if (n >= 3 && n <= 10) || (n >= 13 && n <= 19) {
   108  		return locales.PluralRuleFew
   109  	}
   110  
   111  	return locales.PluralRuleOther
   112  }
   113  
   114  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'gd_GB'
   115  func (gd *gd_GB) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   116  
   117  	n := math.Abs(num)
   118  
   119  	if n == 1 || n == 11 {
   120  		return locales.PluralRuleOne
   121  	} else if n == 2 || n == 12 {
   122  		return locales.PluralRuleTwo
   123  	} else if n == 3 || n == 13 {
   124  		return locales.PluralRuleFew
   125  	}
   126  
   127  	return locales.PluralRuleOther
   128  }
   129  
   130  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'gd_GB'
   131  func (gd *gd_GB) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   132  	return locales.PluralRuleUnknown
   133  }
   134  
   135  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   136  func (gd *gd_GB) MonthAbbreviated(month time.Month) string {
   137  	return gd.monthsAbbreviated[month]
   138  }
   139  
   140  // MonthsAbbreviated returns the locales abbreviated months
   141  func (gd *gd_GB) MonthsAbbreviated() []string {
   142  	return gd.monthsAbbreviated[1:]
   143  }
   144  
   145  // MonthNarrow returns the locales narrow month given the 'month' provided
   146  func (gd *gd_GB) MonthNarrow(month time.Month) string {
   147  	return gd.monthsNarrow[month]
   148  }
   149  
   150  // MonthsNarrow returns the locales narrow months
   151  func (gd *gd_GB) MonthsNarrow() []string {
   152  	return gd.monthsNarrow[1:]
   153  }
   154  
   155  // MonthWide returns the locales wide month given the 'month' provided
   156  func (gd *gd_GB) MonthWide(month time.Month) string {
   157  	return gd.monthsWide[month]
   158  }
   159  
   160  // MonthsWide returns the locales wide months
   161  func (gd *gd_GB) MonthsWide() []string {
   162  	return gd.monthsWide[1:]
   163  }
   164  
   165  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   166  func (gd *gd_GB) WeekdayAbbreviated(weekday time.Weekday) string {
   167  	return gd.daysAbbreviated[weekday]
   168  }
   169  
   170  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   171  func (gd *gd_GB) WeekdaysAbbreviated() []string {
   172  	return gd.daysAbbreviated
   173  }
   174  
   175  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   176  func (gd *gd_GB) WeekdayNarrow(weekday time.Weekday) string {
   177  	return gd.daysNarrow[weekday]
   178  }
   179  
   180  // WeekdaysNarrow returns the locales narrow weekdays
   181  func (gd *gd_GB) WeekdaysNarrow() []string {
   182  	return gd.daysNarrow
   183  }
   184  
   185  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   186  func (gd *gd_GB) WeekdayShort(weekday time.Weekday) string {
   187  	return gd.daysShort[weekday]
   188  }
   189  
   190  // WeekdaysShort returns the locales short weekdays
   191  func (gd *gd_GB) WeekdaysShort() []string {
   192  	return gd.daysShort
   193  }
   194  
   195  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   196  func (gd *gd_GB) WeekdayWide(weekday time.Weekday) string {
   197  	return gd.daysWide[weekday]
   198  }
   199  
   200  // WeekdaysWide returns the locales wide weekdays
   201  func (gd *gd_GB) WeekdaysWide() []string {
   202  	return gd.daysWide
   203  }
   204  
   205  // Decimal returns the decimal point of number
   206  func (gd *gd_GB) Decimal() string {
   207  	return gd.decimal
   208  }
   209  
   210  // Group returns the group of number
   211  func (gd *gd_GB) Group() string {
   212  	return gd.group
   213  }
   214  
   215  // Group returns the minus sign of number
   216  func (gd *gd_GB) Minus() string {
   217  	return gd.minus
   218  }
   219  
   220  // FmtNumber returns 'num' with digits/precision of 'v' for 'gd_GB' and handles both Whole and Real numbers based on 'v'
   221  func (gd *gd_GB) FmtNumber(num float64, v uint64) string {
   222  
   223  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   224  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   225  	count := 0
   226  	inWhole := v == 0
   227  	b := make([]byte, 0, l)
   228  
   229  	for i := len(s) - 1; i >= 0; i-- {
   230  
   231  		if s[i] == '.' {
   232  			b = append(b, gd.decimal[0])
   233  			inWhole = true
   234  			continue
   235  		}
   236  
   237  		if inWhole {
   238  			if count == 3 {
   239  				b = append(b, gd.group[0])
   240  				count = 1
   241  			} else {
   242  				count++
   243  			}
   244  		}
   245  
   246  		b = append(b, s[i])
   247  	}
   248  
   249  	if num < 0 {
   250  		b = append(b, gd.minus[0])
   251  	}
   252  
   253  	// reverse
   254  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   255  		b[i], b[j] = b[j], b[i]
   256  	}
   257  
   258  	return string(b)
   259  }
   260  
   261  // FmtPercent returns 'num' with digits/precision of 'v' for 'gd_GB' and handles both Whole and Real numbers based on 'v'
   262  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   263  func (gd *gd_GB) FmtPercent(num float64, v uint64) string {
   264  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   265  	l := len(s) + 3
   266  	b := make([]byte, 0, l)
   267  
   268  	for i := len(s) - 1; i >= 0; i-- {
   269  
   270  		if s[i] == '.' {
   271  			b = append(b, gd.decimal[0])
   272  			continue
   273  		}
   274  
   275  		b = append(b, s[i])
   276  	}
   277  
   278  	if num < 0 {
   279  		b = append(b, gd.minus[0])
   280  	}
   281  
   282  	// reverse
   283  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   284  		b[i], b[j] = b[j], b[i]
   285  	}
   286  
   287  	b = append(b, gd.percent...)
   288  
   289  	return string(b)
   290  }
   291  
   292  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'gd_GB'
   293  func (gd *gd_GB) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   294  
   295  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   296  	symbol := gd.currencies[currency]
   297  	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   298  	count := 0
   299  	inWhole := v == 0
   300  	b := make([]byte, 0, l)
   301  
   302  	for i := len(s) - 1; i >= 0; i-- {
   303  
   304  		if s[i] == '.' {
   305  			b = append(b, gd.decimal[0])
   306  			inWhole = true
   307  			continue
   308  		}
   309  
   310  		if inWhole {
   311  			if count == 3 {
   312  				b = append(b, gd.group[0])
   313  				count = 1
   314  			} else {
   315  				count++
   316  			}
   317  		}
   318  
   319  		b = append(b, s[i])
   320  	}
   321  
   322  	for j := len(symbol) - 1; j >= 0; j-- {
   323  		b = append(b, symbol[j])
   324  	}
   325  
   326  	if num < 0 {
   327  		b = append(b, gd.minus[0])
   328  	}
   329  
   330  	// reverse
   331  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   332  		b[i], b[j] = b[j], b[i]
   333  	}
   334  
   335  	if int(v) < 2 {
   336  
   337  		if v == 0 {
   338  			b = append(b, gd.decimal...)
   339  		}
   340  
   341  		for i := 0; i < 2-int(v); i++ {
   342  			b = append(b, '0')
   343  		}
   344  	}
   345  
   346  	return string(b)
   347  }
   348  
   349  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'gd_GB'
   350  // in accounting notation.
   351  func (gd *gd_GB) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   352  
   353  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   354  	symbol := gd.currencies[currency]
   355  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   356  	count := 0
   357  	inWhole := v == 0
   358  	b := make([]byte, 0, l)
   359  
   360  	for i := len(s) - 1; i >= 0; i-- {
   361  
   362  		if s[i] == '.' {
   363  			b = append(b, gd.decimal[0])
   364  			inWhole = true
   365  			continue
   366  		}
   367  
   368  		if inWhole {
   369  			if count == 3 {
   370  				b = append(b, gd.group[0])
   371  				count = 1
   372  			} else {
   373  				count++
   374  			}
   375  		}
   376  
   377  		b = append(b, s[i])
   378  	}
   379  
   380  	if num < 0 {
   381  
   382  		for j := len(symbol) - 1; j >= 0; j-- {
   383  			b = append(b, symbol[j])
   384  		}
   385  
   386  		b = append(b, gd.currencyNegativePrefix[0])
   387  
   388  	} else {
   389  
   390  		for j := len(symbol) - 1; j >= 0; j-- {
   391  			b = append(b, symbol[j])
   392  		}
   393  
   394  	}
   395  
   396  	// reverse
   397  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   398  		b[i], b[j] = b[j], b[i]
   399  	}
   400  
   401  	if int(v) < 2 {
   402  
   403  		if v == 0 {
   404  			b = append(b, gd.decimal...)
   405  		}
   406  
   407  		for i := 0; i < 2-int(v); i++ {
   408  			b = append(b, '0')
   409  		}
   410  	}
   411  
   412  	if num < 0 {
   413  		b = append(b, gd.currencyNegativeSuffix...)
   414  	}
   415  
   416  	return string(b)
   417  }
   418  
   419  // FmtDateShort returns the short date representation of 't' for 'gd_GB'
   420  func (gd *gd_GB) FmtDateShort(t time.Time) string {
   421  
   422  	b := make([]byte, 0, 32)
   423  
   424  	if t.Day() < 10 {
   425  		b = append(b, '0')
   426  	}
   427  
   428  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   429  	b = append(b, []byte{0x2f}...)
   430  
   431  	if t.Month() < 10 {
   432  		b = append(b, '0')
   433  	}
   434  
   435  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   436  
   437  	b = append(b, []byte{0x2f}...)
   438  
   439  	if t.Year() > 0 {
   440  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   441  	} else {
   442  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   443  	}
   444  
   445  	return string(b)
   446  }
   447  
   448  // FmtDateMedium returns the medium date representation of 't' for 'gd_GB'
   449  func (gd *gd_GB) FmtDateMedium(t time.Time) string {
   450  
   451  	b := make([]byte, 0, 32)
   452  
   453  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   454  	b = append(b, []byte{0x20}...)
   455  	b = append(b, gd.monthsAbbreviated[t.Month()]...)
   456  	b = append(b, []byte{0x20}...)
   457  
   458  	if t.Year() > 0 {
   459  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   460  	} else {
   461  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   462  	}
   463  
   464  	return string(b)
   465  }
   466  
   467  // FmtDateLong returns the long date representation of 't' for 'gd_GB'
   468  func (gd *gd_GB) FmtDateLong(t time.Time) string {
   469  
   470  	b := make([]byte, 0, 32)
   471  
   472  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   473  	b = append(b, []byte{0x6d, 0x68}...)
   474  	b = append(b, []byte{0x20}...)
   475  	b = append(b, gd.monthsWide[t.Month()]...)
   476  	b = append(b, []byte{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  // FmtDateFull returns the full date representation of 't' for 'gd_GB'
   488  func (gd *gd_GB) FmtDateFull(t time.Time) string {
   489  
   490  	b := make([]byte, 0, 32)
   491  
   492  	b = append(b, gd.daysWide[t.Weekday()]...)
   493  	b = append(b, []byte{0x2c, 0x20}...)
   494  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   495  	b = append(b, []byte{0x6d, 0x68}...)
   496  	b = append(b, []byte{0x20}...)
   497  	b = append(b, gd.monthsWide[t.Month()]...)
   498  	b = append(b, []byte{0x20}...)
   499  
   500  	if t.Year() > 0 {
   501  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   502  	} else {
   503  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   504  	}
   505  
   506  	return string(b)
   507  }
   508  
   509  // FmtTimeShort returns the short time representation of 't' for 'gd_GB'
   510  func (gd *gd_GB) FmtTimeShort(t time.Time) string {
   511  
   512  	b := make([]byte, 0, 32)
   513  
   514  	if t.Hour() < 10 {
   515  		b = append(b, '0')
   516  	}
   517  
   518  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   519  	b = append(b, gd.timeSeparator...)
   520  
   521  	if t.Minute() < 10 {
   522  		b = append(b, '0')
   523  	}
   524  
   525  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   526  
   527  	return string(b)
   528  }
   529  
   530  // FmtTimeMedium returns the medium time representation of 't' for 'gd_GB'
   531  func (gd *gd_GB) FmtTimeMedium(t time.Time) string {
   532  
   533  	b := make([]byte, 0, 32)
   534  
   535  	if t.Hour() < 10 {
   536  		b = append(b, '0')
   537  	}
   538  
   539  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   540  	b = append(b, gd.timeSeparator...)
   541  
   542  	if t.Minute() < 10 {
   543  		b = append(b, '0')
   544  	}
   545  
   546  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   547  	b = append(b, gd.timeSeparator...)
   548  
   549  	if t.Second() < 10 {
   550  		b = append(b, '0')
   551  	}
   552  
   553  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   554  
   555  	return string(b)
   556  }
   557  
   558  // FmtTimeLong returns the long time representation of 't' for 'gd_GB'
   559  func (gd *gd_GB) FmtTimeLong(t time.Time) string {
   560  
   561  	b := make([]byte, 0, 32)
   562  
   563  	if t.Hour() < 10 {
   564  		b = append(b, '0')
   565  	}
   566  
   567  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   568  	b = append(b, gd.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, gd.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  	tz, _ := t.Zone()
   585  	b = append(b, tz...)
   586  
   587  	return string(b)
   588  }
   589  
   590  // FmtTimeFull returns the full time representation of 't' for 'gd_GB'
   591  func (gd *gd_GB) FmtTimeFull(t time.Time) string {
   592  
   593  	b := make([]byte, 0, 32)
   594  
   595  	if t.Hour() < 10 {
   596  		b = append(b, '0')
   597  	}
   598  
   599  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   600  	b = append(b, gd.timeSeparator...)
   601  
   602  	if t.Minute() < 10 {
   603  		b = append(b, '0')
   604  	}
   605  
   606  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   607  	b = append(b, gd.timeSeparator...)
   608  
   609  	if t.Second() < 10 {
   610  		b = append(b, '0')
   611  	}
   612  
   613  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   614  	b = append(b, []byte{0x20}...)
   615  
   616  	tz, _ := t.Zone()
   617  
   618  	if btz, ok := gd.timezones[tz]; ok {
   619  		b = append(b, btz...)
   620  	} else {
   621  		b = append(b, tz...)
   622  	}
   623  
   624  	return string(b)
   625  }
   626  

View as plain text