...

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

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

     1  package ig
     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 ig struct {
    13  	locale             string
    14  	pluralsCardinal    []locales.PluralRule
    15  	pluralsOrdinal     []locales.PluralRule
    16  	pluralsRange       []locales.PluralRule
    17  	decimal            string
    18  	group              string
    19  	minus              string
    20  	percent            string
    21  	percentSuffix      string
    22  	perMille           string
    23  	timeSeparator      string
    24  	inifinity          string
    25  	currencies         []string // idx = enum of currency code
    26  	monthsAbbreviated  []string
    27  	monthsNarrow       []string
    28  	monthsWide         []string
    29  	daysAbbreviated    []string
    30  	daysNarrow         []string
    31  	daysShort          []string
    32  	daysWide           []string
    33  	periodsAbbreviated []string
    34  	periodsNarrow      []string
    35  	periodsShort       []string
    36  	periodsWide        []string
    37  	erasAbbreviated    []string
    38  	erasNarrow         []string
    39  	erasWide           []string
    40  	timezones          map[string]string
    41  }
    42  
    43  // New returns a new instance of translator for the 'ig' locale
    44  func New() locales.Translator {
    45  	return &ig{
    46  		locale:             "ig",
    47  		pluralsCardinal:    []locales.PluralRule{6},
    48  		pluralsOrdinal:     nil,
    49  		pluralsRange:       nil,
    50  		decimal:            "٫",
    51  		group:              "٬",
    52  		minus:              "‏-",
    53  		percent:            "٪‏",
    54  		perMille:           "؉",
    55  		timeSeparator:      ":",
    56  		inifinity:          "∞",
    57  		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", "¥", "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", "₦", "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", "$", "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"},
    58  		percentSuffix:      " ",
    59  		monthsAbbreviated:  []string{"", "Jen", "Feb", "Maa", "Epr", "Mee", "Juu", "Jul", "Ọgọ", "Sep", "Ọkt", "Nov", "Dis"},
    60  		monthsNarrow:       []string{"", "J", "F", "M", "E", "M", "J", "J", "Ọ", "S", "Ọ", "N", "D"},
    61  		monthsWide:         []string{"", "Jenụwarị", "Febrụwarị", "Maachị", "Epreel", "Mee", "Juun", "Julaị", "Ọgọọst", "Septemba", "Ọktoba", "Novemba", "Disemba"},
    62  		daysAbbreviated:    []string{"Ụka", "Mọn", "Tiu", "Wen", "Tọọ", "Fraị", "Sat"},
    63  		daysShort:          []string{"Sọn", "Mọn", "Tiu", "Wen", "Tọọ", "Fraị", "Sat"},
    64  		daysWide:           []string{"Sọndee", "Mọnde", "Tiuzdee", "Wenezdee", "Tọọzdee", "Fraịdee", "Satọdee"},
    65  		periodsAbbreviated: []string{"A.M.", "P.M."},
    66  		periodsNarrow:      []string{"A.M.", "P.M."},
    67  		periodsWide:        []string{"N’ụtụtụ", "N’abali"},
    68  		erasAbbreviated:    []string{"T.K.", "A.K."},
    69  		erasNarrow:         []string{"T.K.", "A.K."},
    70  		erasWide:           []string{"Tupu Kraist", "Afọ Kraịst"},
    71  		timezones:          map[string]string{"ACDT": "Oge Ihe Etiti Australia", "ACST": "Oge Izugbe Etiti Australia", "ACWDT": "Oge Ihe Mpaghara Ọdịda Anyanwụ Etiti Australia", "ACWST": "Oge Izugbe Mpaghara Ọdịda Anyanwụ Etiti Australia", "ADT": "Oge Ihe Mpaghara Atlantic", "AEDT": "Oge Ihe Mpaghara Ọwụwa Anyanwụ Australia", "AEST": "Oge Izugbe Mpaghara Ọwụwa Anyanwụ Australia", "AKDT": "Oge Ihe Alaska", "AKST": "Oge Izugbe Alaska", "ARST": "Oge Okpomọkụ Argentina", "ART": "Oge Izugbe Argentina", "AST": "Oge Izugbe Mpaghara Atlantic", "AWDT": "Oge Ihe Mpaghara Ọdịda Anyanwụ Australia", "AWST": "Oge Izugbe Mpaghara Ọdịda Anyanwụ Australia", "BOT": "Oge Bolivia", "BT": "Oge Bhutan", "CAT": "Oge Etiti Afrịka", "CDT": "Oge Ihe Mpaghara Etiti", "CHADT": "Oge Ihe Chatham", "CHAST": "Oge Izugbe Chatham", "CLST": "Oge Okpomọkụ Chile", "CLT": "Oge Izugbe Chile", "COST": "Oge Okpomọkụ Columbia", "COT": "Oge Izugbe Columbia", "CST": "Oge Izugbe Mpaghara Etiti", "ChST": "Oge Izugbe Chamorro", "EAT": "Oge Mpaghara Ọwụwa Anyanwụ Afrịka", "ECT": "Oge Ecuador", "EDT": "Oge Ihe Mpaghara Ọwụwa Anyanwụ", "EST": "Oge Izugbe Mpaghara Ọwụwa Anyanwụ", "GFT": "Oge French Guiana", "GMT": "Oge Mpaghara Greemwich Mean", "GST": "Oge Izugbe Gulf", "GYT": "Oge Guyana", "HADT": "Oge Ihe Hawaii-Aleutian", "HAST": "Oge Izugbe Hawaii-Aleutian", "HAT": "Oge Ihe Newfoundland", "HECU": "Oge Ihe Mpaghara Cuba", "HEEG": "Oge Okpomọkụ Mpaghara Ọwụwa Anyanwụ Greenland", "HENOMX": "Oge Ihe Northwest Mexico", "HEOG": "Oge Okpomọkụ Mpaghara Ọdịda Anyanwụ Greenland", "HEPM": "Oge Ihe St. Pierre & Miquelon", "HEPMX": "Oge Ihe Mexican Pacific", "HKST": "Oge Okpomọkụ Hong Kong", "HKT": "Oge Izugbe Hong Kong", "HNCU": "Oge Izugbe Cuba", "HNEG": "Oge Izugbe Mpaghara Ọwụwa Anyanwụ Greenland", "HNNOMX": "Oge Izugbe Northwest Mexico", "HNOG": "Oge Izugbe Mpaghara Ọdịda Anyanwụ Greenland", "HNPM": "Oge Izugbe St. Pierre & Miquelon", "HNPMX": "Oge Izugbe Mexican Pacific", "HNT": "Oge Izugbe Newfoundland", "IST": "Oge Izugbe India", "JDT": "Oge Ihe Japan", "JST": "Oge Izugbe Japan", "LHDT": "Oge Ihe Lord Howe", "LHST": "Oge Izugbe Lord Howe", "MDT": "Oge Ihe Mpaghara Ugwu", "MESZ": "Oge Okpomọkụ Mpaghara Etiti Europe", "MEZ": "Oge Izugbe Mpaghara Etiti Europe", "MST": "Oge Izugbe Mpaghara Ugwu", "MYT": "Oge Malaysia", "NZDT": "Oge Ihe New Zealand", "NZST": "Oge Izugbe New Zealand", "OESZ": "Oge Okpomọkụ Mpaghara Ọwụwa Anyanwụ Europe", "OEZ": "Oge Izugbe Mpaghara Ọwụwa Anyanwụ Europe", "PDT": "Oge Ihe Mpaghara Pacific", "PST": "Oge Izugbe Mpaghara Pacific", "SAST": "Oge Izugbe Mpaghara Mgbada Ugwu Afrịka", "SGT": "Oge Izugbe Singapore", "SRT": "Oge Suriname", "TMST": "Oge Okpomọkụ Turkmenist", "TMT": "Oge Izugbe Turkmenist", "UYST": "Oge Okpomọkụ Uruguay", "UYT": "Oge Izugbe Uruguay", "VET": "Oge Venezuela", "WARST": "Oge Okpomọkụ Mpaghara Ọdịda Anyanwụ Argentina", "WART": "Oge Izugbe Mpaghara Ọdịda Anyanwụ Argentina", "WAST": "Oge Okpomọkụ Mpaghara Ọdịda Anyanwụ Afrịka", "WAT": "Oge Izugbe Mpaghara Ọdịda Anyanwụ Afrịka", "WESZ": "Oge Okpomọkụ Mpaghara Ọdịda Anyanwụ Europe", "WEZ": "Oge Izugbe Mpaghara Ọdịda Anyanwụ Europe", "WIB": "Oge Mpaghara Ọdịda Anyanwụ Indonesia", "WIT": "Oge Mpaghara Ọwụwa Anyanwụ Indonesia", "WITA": "Oge Etiti Indonesia", "∅∅∅": "Oge Okpomọkụ Peru"},
    72  	}
    73  }
    74  
    75  // Locale returns the current translators string locale
    76  func (ig *ig) Locale() string {
    77  	return ig.locale
    78  }
    79  
    80  // PluralsCardinal returns the list of cardinal plural rules associated with 'ig'
    81  func (ig *ig) PluralsCardinal() []locales.PluralRule {
    82  	return ig.pluralsCardinal
    83  }
    84  
    85  // PluralsOrdinal returns the list of ordinal plural rules associated with 'ig'
    86  func (ig *ig) PluralsOrdinal() []locales.PluralRule {
    87  	return ig.pluralsOrdinal
    88  }
    89  
    90  // PluralsRange returns the list of range plural rules associated with 'ig'
    91  func (ig *ig) PluralsRange() []locales.PluralRule {
    92  	return ig.pluralsRange
    93  }
    94  
    95  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ig'
    96  func (ig *ig) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    97  	return locales.PluralRuleOther
    98  }
    99  
   100  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'ig'
   101  func (ig *ig) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   102  	return locales.PluralRuleUnknown
   103  }
   104  
   105  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ig'
   106  func (ig *ig) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   107  	return locales.PluralRuleUnknown
   108  }
   109  
   110  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   111  func (ig *ig) MonthAbbreviated(month time.Month) string {
   112  	return ig.monthsAbbreviated[month]
   113  }
   114  
   115  // MonthsAbbreviated returns the locales abbreviated months
   116  func (ig *ig) MonthsAbbreviated() []string {
   117  	return ig.monthsAbbreviated[1:]
   118  }
   119  
   120  // MonthNarrow returns the locales narrow month given the 'month' provided
   121  func (ig *ig) MonthNarrow(month time.Month) string {
   122  	return ig.monthsNarrow[month]
   123  }
   124  
   125  // MonthsNarrow returns the locales narrow months
   126  func (ig *ig) MonthsNarrow() []string {
   127  	return ig.monthsNarrow[1:]
   128  }
   129  
   130  // MonthWide returns the locales wide month given the 'month' provided
   131  func (ig *ig) MonthWide(month time.Month) string {
   132  	return ig.monthsWide[month]
   133  }
   134  
   135  // MonthsWide returns the locales wide months
   136  func (ig *ig) MonthsWide() []string {
   137  	return ig.monthsWide[1:]
   138  }
   139  
   140  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   141  func (ig *ig) WeekdayAbbreviated(weekday time.Weekday) string {
   142  	return ig.daysAbbreviated[weekday]
   143  }
   144  
   145  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   146  func (ig *ig) WeekdaysAbbreviated() []string {
   147  	return ig.daysAbbreviated
   148  }
   149  
   150  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   151  func (ig *ig) WeekdayNarrow(weekday time.Weekday) string {
   152  	return ig.daysNarrow[weekday]
   153  }
   154  
   155  // WeekdaysNarrow returns the locales narrow weekdays
   156  func (ig *ig) WeekdaysNarrow() []string {
   157  	return ig.daysNarrow
   158  }
   159  
   160  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   161  func (ig *ig) WeekdayShort(weekday time.Weekday) string {
   162  	return ig.daysShort[weekday]
   163  }
   164  
   165  // WeekdaysShort returns the locales short weekdays
   166  func (ig *ig) WeekdaysShort() []string {
   167  	return ig.daysShort
   168  }
   169  
   170  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   171  func (ig *ig) WeekdayWide(weekday time.Weekday) string {
   172  	return ig.daysWide[weekday]
   173  }
   174  
   175  // WeekdaysWide returns the locales wide weekdays
   176  func (ig *ig) WeekdaysWide() []string {
   177  	return ig.daysWide
   178  }
   179  
   180  // Decimal returns the decimal point of number
   181  func (ig *ig) Decimal() string {
   182  	return ig.decimal
   183  }
   184  
   185  // Group returns the group of number
   186  func (ig *ig) Group() string {
   187  	return ig.group
   188  }
   189  
   190  // Group returns the minus sign of number
   191  func (ig *ig) Minus() string {
   192  	return ig.minus
   193  }
   194  
   195  // FmtNumber returns 'num' with digits/precision of 'v' for 'ig' and handles both Whole and Real numbers based on 'v'
   196  func (ig *ig) FmtNumber(num float64, v uint64) string {
   197  
   198  	return strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   199  }
   200  
   201  // FmtPercent returns 'num' with digits/precision of 'v' for 'ig' and handles both Whole and Real numbers based on 'v'
   202  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   203  func (ig *ig) FmtPercent(num float64, v uint64) string {
   204  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   205  	l := len(s) + 13
   206  	b := make([]byte, 0, l)
   207  
   208  	for i := len(s) - 1; i >= 0; i-- {
   209  
   210  		if s[i] == '.' {
   211  			for j := len(ig.decimal) - 1; j >= 0; j-- {
   212  				b = append(b, ig.decimal[j])
   213  			}
   214  			continue
   215  		}
   216  
   217  		b = append(b, s[i])
   218  	}
   219  
   220  	if num < 0 {
   221  		for j := len(ig.minus) - 1; j >= 0; j-- {
   222  			b = append(b, ig.minus[j])
   223  		}
   224  	}
   225  
   226  	// reverse
   227  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   228  		b[i], b[j] = b[j], b[i]
   229  	}
   230  
   231  	b = append(b, ig.percentSuffix...)
   232  
   233  	b = append(b, ig.percent...)
   234  
   235  	return string(b)
   236  }
   237  
   238  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ig'
   239  func (ig *ig) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   240  
   241  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   242  	symbol := ig.currencies[currency]
   243  	l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
   244  	count := 0
   245  	inWhole := v == 0
   246  	b := make([]byte, 0, l)
   247  
   248  	for i := len(s) - 1; i >= 0; i-- {
   249  
   250  		if s[i] == '.' {
   251  			for j := len(ig.decimal) - 1; j >= 0; j-- {
   252  				b = append(b, ig.decimal[j])
   253  			}
   254  			inWhole = true
   255  			continue
   256  		}
   257  
   258  		if inWhole {
   259  			if count == 3 {
   260  				for j := len(ig.group) - 1; j >= 0; j-- {
   261  					b = append(b, ig.group[j])
   262  				}
   263  				count = 1
   264  			} else {
   265  				count++
   266  			}
   267  		}
   268  
   269  		b = append(b, s[i])
   270  	}
   271  
   272  	for j := len(symbol) - 1; j >= 0; j-- {
   273  		b = append(b, symbol[j])
   274  	}
   275  
   276  	if num < 0 {
   277  		for j := len(ig.minus) - 1; j >= 0; j-- {
   278  			b = append(b, ig.minus[j])
   279  		}
   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  	if int(v) < 2 {
   288  
   289  		if v == 0 {
   290  			b = append(b, ig.decimal...)
   291  		}
   292  
   293  		for i := 0; i < 2-int(v); i++ {
   294  			b = append(b, '0')
   295  		}
   296  	}
   297  
   298  	return string(b)
   299  }
   300  
   301  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ig'
   302  // in accounting notation.
   303  func (ig *ig) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   304  
   305  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   306  	symbol := ig.currencies[currency]
   307  	l := len(s) + len(symbol) + 6 + 2*len(s[:len(s)-int(v)-1])/3
   308  	count := 0
   309  	inWhole := v == 0
   310  	b := make([]byte, 0, l)
   311  
   312  	for i := len(s) - 1; i >= 0; i-- {
   313  
   314  		if s[i] == '.' {
   315  			for j := len(ig.decimal) - 1; j >= 0; j-- {
   316  				b = append(b, ig.decimal[j])
   317  			}
   318  			inWhole = true
   319  			continue
   320  		}
   321  
   322  		if inWhole {
   323  			if count == 3 {
   324  				for j := len(ig.group) - 1; j >= 0; j-- {
   325  					b = append(b, ig.group[j])
   326  				}
   327  				count = 1
   328  			} else {
   329  				count++
   330  			}
   331  		}
   332  
   333  		b = append(b, s[i])
   334  	}
   335  
   336  	if num < 0 {
   337  
   338  		for j := len(symbol) - 1; j >= 0; j-- {
   339  			b = append(b, symbol[j])
   340  		}
   341  
   342  		for j := len(ig.minus) - 1; j >= 0; j-- {
   343  			b = append(b, ig.minus[j])
   344  		}
   345  
   346  	} else {
   347  
   348  		for j := len(symbol) - 1; j >= 0; j-- {
   349  			b = append(b, symbol[j])
   350  		}
   351  
   352  	}
   353  
   354  	// reverse
   355  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   356  		b[i], b[j] = b[j], b[i]
   357  	}
   358  
   359  	if int(v) < 2 {
   360  
   361  		if v == 0 {
   362  			b = append(b, ig.decimal...)
   363  		}
   364  
   365  		for i := 0; i < 2-int(v); i++ {
   366  			b = append(b, '0')
   367  		}
   368  	}
   369  
   370  	return string(b)
   371  }
   372  
   373  // FmtDateShort returns the short date representation of 't' for 'ig'
   374  func (ig *ig) FmtDateShort(t time.Time) string {
   375  
   376  	b := make([]byte, 0, 32)
   377  
   378  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   379  	b = append(b, []byte{0x2f}...)
   380  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   381  	b = append(b, []byte{0x2f}...)
   382  
   383  	if t.Year() > 9 {
   384  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   385  	} else {
   386  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   387  	}
   388  
   389  	return string(b)
   390  }
   391  
   392  // FmtDateMedium returns the medium date representation of 't' for 'ig'
   393  func (ig *ig) FmtDateMedium(t time.Time) string {
   394  
   395  	b := make([]byte, 0, 32)
   396  
   397  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   398  	b = append(b, []byte{0x20}...)
   399  	b = append(b, ig.monthsAbbreviated[t.Month()]...)
   400  	b = append(b, []byte{0x20}...)
   401  
   402  	if t.Year() > 0 {
   403  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   404  	} else {
   405  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   406  	}
   407  
   408  	return string(b)
   409  }
   410  
   411  // FmtDateLong returns the long date representation of 't' for 'ig'
   412  func (ig *ig) FmtDateLong(t time.Time) string {
   413  
   414  	b := make([]byte, 0, 32)
   415  
   416  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   417  	b = append(b, []byte{0x20}...)
   418  	b = append(b, ig.monthsWide[t.Month()]...)
   419  	b = append(b, []byte{0x20}...)
   420  
   421  	if t.Year() > 0 {
   422  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   423  	} else {
   424  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   425  	}
   426  
   427  	return string(b)
   428  }
   429  
   430  // FmtDateFull returns the full date representation of 't' for 'ig'
   431  func (ig *ig) FmtDateFull(t time.Time) string {
   432  
   433  	b := make([]byte, 0, 32)
   434  
   435  	b = append(b, ig.daysWide[t.Weekday()]...)
   436  	b = append(b, []byte{0x2c, 0x20}...)
   437  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   438  	b = append(b, []byte{0x20}...)
   439  	b = append(b, ig.monthsWide[t.Month()]...)
   440  	b = append(b, []byte{0x20}...)
   441  
   442  	if t.Year() > 0 {
   443  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   444  	} else {
   445  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   446  	}
   447  
   448  	return string(b)
   449  }
   450  
   451  // FmtTimeShort returns the short time representation of 't' for 'ig'
   452  func (ig *ig) FmtTimeShort(t time.Time) string {
   453  
   454  	b := make([]byte, 0, 32)
   455  
   456  	if t.Hour() < 10 {
   457  		b = append(b, '0')
   458  	}
   459  
   460  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   461  	b = append(b, ig.timeSeparator...)
   462  
   463  	if t.Minute() < 10 {
   464  		b = append(b, '0')
   465  	}
   466  
   467  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   468  
   469  	return string(b)
   470  }
   471  
   472  // FmtTimeMedium returns the medium time representation of 't' for 'ig'
   473  func (ig *ig) FmtTimeMedium(t time.Time) string {
   474  
   475  	b := make([]byte, 0, 32)
   476  
   477  	if t.Hour() < 10 {
   478  		b = append(b, '0')
   479  	}
   480  
   481  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   482  	b = append(b, ig.timeSeparator...)
   483  
   484  	if t.Minute() < 10 {
   485  		b = append(b, '0')
   486  	}
   487  
   488  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   489  	b = append(b, ig.timeSeparator...)
   490  
   491  	if t.Second() < 10 {
   492  		b = append(b, '0')
   493  	}
   494  
   495  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   496  
   497  	return string(b)
   498  }
   499  
   500  // FmtTimeLong returns the long time representation of 't' for 'ig'
   501  func (ig *ig) FmtTimeLong(t time.Time) string {
   502  
   503  	b := make([]byte, 0, 32)
   504  
   505  	if t.Hour() < 10 {
   506  		b = append(b, '0')
   507  	}
   508  
   509  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   510  	b = append(b, ig.timeSeparator...)
   511  
   512  	if t.Minute() < 10 {
   513  		b = append(b, '0')
   514  	}
   515  
   516  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   517  	b = append(b, ig.timeSeparator...)
   518  
   519  	if t.Second() < 10 {
   520  		b = append(b, '0')
   521  	}
   522  
   523  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   524  	b = append(b, []byte{0x20}...)
   525  
   526  	tz, _ := t.Zone()
   527  	b = append(b, tz...)
   528  
   529  	return string(b)
   530  }
   531  
   532  // FmtTimeFull returns the full time representation of 't' for 'ig'
   533  func (ig *ig) FmtTimeFull(t time.Time) string {
   534  
   535  	b := make([]byte, 0, 32)
   536  
   537  	if t.Hour() < 10 {
   538  		b = append(b, '0')
   539  	}
   540  
   541  	b = strconv.AppendInt(b, int64(t.Hour()), 10)
   542  	b = append(b, ig.timeSeparator...)
   543  
   544  	if t.Minute() < 10 {
   545  		b = append(b, '0')
   546  	}
   547  
   548  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   549  	b = append(b, ig.timeSeparator...)
   550  
   551  	if t.Second() < 10 {
   552  		b = append(b, '0')
   553  	}
   554  
   555  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   556  	b = append(b, []byte{0x20}...)
   557  
   558  	tz, _ := t.Zone()
   559  
   560  	if btz, ok := ig.timezones[tz]; ok {
   561  		b = append(b, btz...)
   562  	} else {
   563  		b = append(b, tz...)
   564  	}
   565  
   566  	return string(b)
   567  }
   568  

View as plain text