...

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

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

     1  package en_IN
     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 en_IN 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  	monthsAbbreviated  []string
    26  	monthsNarrow       []string
    27  	monthsWide         []string
    28  	daysAbbreviated    []string
    29  	daysNarrow         []string
    30  	daysShort          []string
    31  	daysWide           []string
    32  	periodsAbbreviated []string
    33  	periodsNarrow      []string
    34  	periodsShort       []string
    35  	periodsWide        []string
    36  	erasAbbreviated    []string
    37  	erasNarrow         []string
    38  	erasWide           []string
    39  	timezones          map[string]string
    40  }
    41  
    42  // New returns a new instance of translator for the 'en_IN' locale
    43  func New() locales.Translator {
    44  	return &en_IN{
    45  		locale:             "en_IN",
    46  		pluralsCardinal:    []locales.PluralRule{2, 6},
    47  		pluralsOrdinal:     []locales.PluralRule{2, 3, 4, 6},
    48  		pluralsRange:       []locales.PluralRule{6},
    49  		decimal:            ".",
    50  		group:              ",",
    51  		minus:              "-",
    52  		percent:            "%",
    53  		perMille:           "‰",
    54  		timeSeparator:      ":",
    55  		inifinity:          "∞",
    56  		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"},
    57  		monthsAbbreviated:  []string{"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
    58  		monthsNarrow:       []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
    59  		monthsWide:         []string{"", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"},
    60  		daysAbbreviated:    []string{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
    61  		daysNarrow:         []string{"S", "M", "T", "W", "T", "F", "S"},
    62  		daysShort:          []string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"},
    63  		daysWide:           []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"},
    64  		periodsAbbreviated: []string{"am", "pm"},
    65  		periodsNarrow:      []string{"", "pm"},
    66  		periodsWide:        []string{"am", "pm"},
    67  		erasAbbreviated:    []string{"BC", "AD"},
    68  		erasNarrow:         []string{"B", "A"},
    69  		erasWide:           []string{"Before Christ", "Anno Domini"},
    70  		timezones:          map[string]string{"ACDT": "Australian Central Daylight Time", "ACST": "Australian Central Standard Time", "ACWDT": "Australian Central Western Daylight Time", "ACWST": "Australian Central Western Standard Time", "ADT": "Atlantic Daylight Time", "AEDT": "Australian Eastern Daylight Time", "AEST": "Australian Eastern Standard Time", "AKDT": "Alaska Daylight Time", "AKST": "Alaska Standard Time", "ARST": "Argentina Summer Time", "ART": "Argentina Standard Time", "AST": "Atlantic Standard Time", "AWDT": "Australian Western Daylight Time", "AWST": "Australian Western Standard Time", "BOT": "Bolivia Time", "BT": "Bhutan Time", "CAT": "Central Africa Time", "CDT": "Central Daylight Time", "CHADT": "Chatham Daylight Time", "CHAST": "Chatham Standard Time", "CLST": "Chile Summer Time", "CLT": "Chile Standard Time", "COST": "Colombia Summer Time", "COT": "Colombia Standard Time", "CST": "Central Standard Time", "ChST": "Chamorro Standard Time", "EAT": "East Africa Time", "ECT": "Ecuador Time", "EDT": "Eastern Daylight Time", "EST": "Eastern Standard Time", "GFT": "French Guiana Time", "GMT": "Greenwich Mean Time", "GST": "Gulf Standard Time", "GYT": "Guyana Time", "HADT": "Hawaii-Aleutian Daylight Time", "HAST": "Hawaii-Aleutian Standard Time", "HAT": "Newfoundland Daylight Time", "HECU": "Cuba Daylight Time", "HEEG": "East Greenland Summer Time", "HENOMX": "Northwest Mexico Daylight Time", "HEOG": "West Greenland Summer Time", "HEPM": "St Pierre & Miquelon Daylight Time", "HEPMX": "Mexican Pacific Daylight Time", "HKST": "Hong Kong Summer Time", "HKT": "Hong Kong Standard Time", "HNCU": "Cuba Standard Time", "HNEG": "East Greenland Standard Time", "HNNOMX": "Northwest Mexico Standard Time", "HNOG": "West Greenland Standard Time", "HNPM": "St Pierre & Miquelon Standard Time", "HNPMX": "Mexican Pacific Standard Time", "HNT": "Newfoundland Standard Time", "IST": "India Standard Time", "JDT": "Japan Daylight Time", "JST": "Japan Standard Time", "LHDT": "Lord Howe Daylight Time", "LHST": "Lord Howe Standard Time", "MDT": "Mountain Daylight Time", "MESZ": "Central European Summer Time", "MEZ": "Central European Standard Time", "MST": "Mountain Standard Time", "MYT": "Malaysia Time", "NZDT": "New Zealand Daylight Time", "NZST": "New Zealand Standard Time", "OESZ": "Eastern European Summer Time", "OEZ": "Eastern European Standard Time", "PDT": "Pacific Daylight Time", "PST": "Pacific Standard Time", "SAST": "South Africa Standard Time", "SGT": "Singapore Standard Time", "SRT": "Suriname Time", "TMST": "Turkmenistan Summer Time", "TMT": "Turkmenistan Standard Time", "UYST": "Uruguay Summer Time", "UYT": "Uruguay Standard Time", "VET": "Venezuela Time", "WARST": "Western Argentina Summer Time", "WART": "Western Argentina Standard Time", "WAST": "West Africa Summer Time", "WAT": "West Africa Standard Time", "WESZ": "Western European Summer Time", "WEZ": "Western European Standard Time", "WIB": "Western Indonesia Time", "WIT": "Eastern Indonesia Time", "WITA": "Central Indonesia Time", "∅∅∅": "Peru Summer Time"},
    71  	}
    72  }
    73  
    74  // Locale returns the current translators string locale
    75  func (en *en_IN) Locale() string {
    76  	return en.locale
    77  }
    78  
    79  // PluralsCardinal returns the list of cardinal plural rules associated with 'en_IN'
    80  func (en *en_IN) PluralsCardinal() []locales.PluralRule {
    81  	return en.pluralsCardinal
    82  }
    83  
    84  // PluralsOrdinal returns the list of ordinal plural rules associated with 'en_IN'
    85  func (en *en_IN) PluralsOrdinal() []locales.PluralRule {
    86  	return en.pluralsOrdinal
    87  }
    88  
    89  // PluralsRange returns the list of range plural rules associated with 'en_IN'
    90  func (en *en_IN) PluralsRange() []locales.PluralRule {
    91  	return en.pluralsRange
    92  }
    93  
    94  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'en_IN'
    95  func (en *en_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
    96  
    97  	n := math.Abs(num)
    98  	i := int64(n)
    99  
   100  	if i == 1 && v == 0 {
   101  		return locales.PluralRuleOne
   102  	}
   103  
   104  	return locales.PluralRuleOther
   105  }
   106  
   107  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'en_IN'
   108  func (en *en_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   109  
   110  	n := math.Abs(num)
   111  	nMod10 := math.Mod(n, 10)
   112  	nMod100 := math.Mod(n, 100)
   113  
   114  	if nMod10 == 1 && nMod100 != 11 {
   115  		return locales.PluralRuleOne
   116  	} else if nMod10 == 2 && nMod100 != 12 {
   117  		return locales.PluralRuleTwo
   118  	} else if nMod10 == 3 && nMod100 != 13 {
   119  		return locales.PluralRuleFew
   120  	}
   121  
   122  	return locales.PluralRuleOther
   123  }
   124  
   125  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'en_IN'
   126  func (en *en_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   127  	return locales.PluralRuleOther
   128  }
   129  
   130  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   131  func (en *en_IN) MonthAbbreviated(month time.Month) string {
   132  	return en.monthsAbbreviated[month]
   133  }
   134  
   135  // MonthsAbbreviated returns the locales abbreviated months
   136  func (en *en_IN) MonthsAbbreviated() []string {
   137  	return en.monthsAbbreviated[1:]
   138  }
   139  
   140  // MonthNarrow returns the locales narrow month given the 'month' provided
   141  func (en *en_IN) MonthNarrow(month time.Month) string {
   142  	return en.monthsNarrow[month]
   143  }
   144  
   145  // MonthsNarrow returns the locales narrow months
   146  func (en *en_IN) MonthsNarrow() []string {
   147  	return en.monthsNarrow[1:]
   148  }
   149  
   150  // MonthWide returns the locales wide month given the 'month' provided
   151  func (en *en_IN) MonthWide(month time.Month) string {
   152  	return en.monthsWide[month]
   153  }
   154  
   155  // MonthsWide returns the locales wide months
   156  func (en *en_IN) MonthsWide() []string {
   157  	return en.monthsWide[1:]
   158  }
   159  
   160  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   161  func (en *en_IN) WeekdayAbbreviated(weekday time.Weekday) string {
   162  	return en.daysAbbreviated[weekday]
   163  }
   164  
   165  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   166  func (en *en_IN) WeekdaysAbbreviated() []string {
   167  	return en.daysAbbreviated
   168  }
   169  
   170  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   171  func (en *en_IN) WeekdayNarrow(weekday time.Weekday) string {
   172  	return en.daysNarrow[weekday]
   173  }
   174  
   175  // WeekdaysNarrow returns the locales narrow weekdays
   176  func (en *en_IN) WeekdaysNarrow() []string {
   177  	return en.daysNarrow
   178  }
   179  
   180  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   181  func (en *en_IN) WeekdayShort(weekday time.Weekday) string {
   182  	return en.daysShort[weekday]
   183  }
   184  
   185  // WeekdaysShort returns the locales short weekdays
   186  func (en *en_IN) WeekdaysShort() []string {
   187  	return en.daysShort
   188  }
   189  
   190  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   191  func (en *en_IN) WeekdayWide(weekday time.Weekday) string {
   192  	return en.daysWide[weekday]
   193  }
   194  
   195  // WeekdaysWide returns the locales wide weekdays
   196  func (en *en_IN) WeekdaysWide() []string {
   197  	return en.daysWide
   198  }
   199  
   200  // Decimal returns the decimal point of number
   201  func (en *en_IN) Decimal() string {
   202  	return en.decimal
   203  }
   204  
   205  // Group returns the group of number
   206  func (en *en_IN) Group() string {
   207  	return en.group
   208  }
   209  
   210  // Group returns the minus sign of number
   211  func (en *en_IN) Minus() string {
   212  	return en.minus
   213  }
   214  
   215  // FmtNumber returns 'num' with digits/precision of 'v' for 'en_IN' and handles both Whole and Real numbers based on 'v'
   216  func (en *en_IN) FmtNumber(num float64, v uint64) string {
   217  
   218  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   219  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   220  	count := 0
   221  	inWhole := v == 0
   222  	inSecondary := false
   223  	groupThreshold := 3
   224  
   225  	b := make([]byte, 0, l)
   226  
   227  	for i := len(s) - 1; i >= 0; i-- {
   228  
   229  		if s[i] == '.' {
   230  			b = append(b, en.decimal[0])
   231  			inWhole = true
   232  			continue
   233  		}
   234  
   235  		if inWhole {
   236  
   237  			if count == groupThreshold {
   238  				b = append(b, en.group[0])
   239  				count = 1
   240  
   241  				if !inSecondary {
   242  					inSecondary = true
   243  					groupThreshold = 2
   244  				}
   245  			} else {
   246  				count++
   247  			}
   248  		}
   249  
   250  		b = append(b, s[i])
   251  	}
   252  
   253  	if num < 0 {
   254  		b = append(b, en.minus[0])
   255  	}
   256  
   257  	// reverse
   258  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   259  		b[i], b[j] = b[j], b[i]
   260  	}
   261  
   262  	return string(b)
   263  }
   264  
   265  // FmtPercent returns 'num' with digits/precision of 'v' for 'en_IN' and handles both Whole and Real numbers based on 'v'
   266  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   267  func (en *en_IN) FmtPercent(num float64, v uint64) string {
   268  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   269  	l := len(s) + 3
   270  	b := make([]byte, 0, l)
   271  
   272  	for i := len(s) - 1; i >= 0; i-- {
   273  
   274  		if s[i] == '.' {
   275  			b = append(b, en.decimal[0])
   276  			continue
   277  		}
   278  
   279  		b = append(b, s[i])
   280  	}
   281  
   282  	if num < 0 {
   283  		b = append(b, en.minus[0])
   284  	}
   285  
   286  	// reverse
   287  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   288  		b[i], b[j] = b[j], b[i]
   289  	}
   290  
   291  	b = append(b, en.percent...)
   292  
   293  	return string(b)
   294  }
   295  
   296  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'en_IN'
   297  func (en *en_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   298  
   299  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   300  	symbol := en.currencies[currency]
   301  	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   302  	count := 0
   303  	inWhole := v == 0
   304  	inSecondary := false
   305  	groupThreshold := 3
   306  
   307  	b := make([]byte, 0, l)
   308  
   309  	for i := len(s) - 1; i >= 0; i-- {
   310  
   311  		if s[i] == '.' {
   312  			b = append(b, en.decimal[0])
   313  			inWhole = true
   314  			continue
   315  		}
   316  
   317  		if inWhole {
   318  
   319  			if count == groupThreshold {
   320  				b = append(b, en.group[0])
   321  				count = 1
   322  
   323  				if !inSecondary {
   324  					inSecondary = true
   325  					groupThreshold = 2
   326  				}
   327  			} else {
   328  				count++
   329  			}
   330  		}
   331  
   332  		b = append(b, s[i])
   333  	}
   334  
   335  	for j := len(symbol) - 1; j >= 0; j-- {
   336  		b = append(b, symbol[j])
   337  	}
   338  
   339  	if num < 0 {
   340  		b = append(b, en.minus[0])
   341  	}
   342  
   343  	// reverse
   344  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   345  		b[i], b[j] = b[j], b[i]
   346  	}
   347  
   348  	if int(v) < 2 {
   349  
   350  		if v == 0 {
   351  			b = append(b, en.decimal...)
   352  		}
   353  
   354  		for i := 0; i < 2-int(v); i++ {
   355  			b = append(b, '0')
   356  		}
   357  	}
   358  
   359  	return string(b)
   360  }
   361  
   362  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'en_IN'
   363  // in accounting notation.
   364  func (en *en_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   365  
   366  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   367  	symbol := en.currencies[currency]
   368  	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   369  	count := 0
   370  	inWhole := v == 0
   371  	inSecondary := false
   372  	groupThreshold := 3
   373  
   374  	b := make([]byte, 0, l)
   375  
   376  	for i := len(s) - 1; i >= 0; i-- {
   377  
   378  		if s[i] == '.' {
   379  			b = append(b, en.decimal[0])
   380  			inWhole = true
   381  			continue
   382  		}
   383  
   384  		if inWhole {
   385  
   386  			if count == groupThreshold {
   387  				b = append(b, en.group[0])
   388  				count = 1
   389  
   390  				if !inSecondary {
   391  					inSecondary = true
   392  					groupThreshold = 2
   393  				}
   394  			} else {
   395  				count++
   396  			}
   397  		}
   398  
   399  		b = append(b, s[i])
   400  	}
   401  
   402  	if num < 0 {
   403  
   404  		for j := len(symbol) - 1; j >= 0; j-- {
   405  			b = append(b, symbol[j])
   406  		}
   407  
   408  		b = append(b, en.minus[0])
   409  
   410  	} else {
   411  
   412  		for j := len(symbol) - 1; j >= 0; j-- {
   413  			b = append(b, symbol[j])
   414  		}
   415  
   416  	}
   417  
   418  	// reverse
   419  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   420  		b[i], b[j] = b[j], b[i]
   421  	}
   422  
   423  	if int(v) < 2 {
   424  
   425  		if v == 0 {
   426  			b = append(b, en.decimal...)
   427  		}
   428  
   429  		for i := 0; i < 2-int(v); i++ {
   430  			b = append(b, '0')
   431  		}
   432  	}
   433  
   434  	return string(b)
   435  }
   436  
   437  // FmtDateShort returns the short date representation of 't' for 'en_IN'
   438  func (en *en_IN) FmtDateShort(t time.Time) string {
   439  
   440  	b := make([]byte, 0, 32)
   441  
   442  	if t.Day() < 10 {
   443  		b = append(b, '0')
   444  	}
   445  
   446  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   447  	b = append(b, []byte{0x2f}...)
   448  
   449  	if t.Month() < 10 {
   450  		b = append(b, '0')
   451  	}
   452  
   453  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   454  
   455  	b = append(b, []byte{0x2f}...)
   456  
   457  	if t.Year() > 9 {
   458  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   459  	} else {
   460  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   461  	}
   462  
   463  	return string(b)
   464  }
   465  
   466  // FmtDateMedium returns the medium date representation of 't' for 'en_IN'
   467  func (en *en_IN) FmtDateMedium(t time.Time) string {
   468  
   469  	b := make([]byte, 0, 32)
   470  
   471  	if t.Day() < 10 {
   472  		b = append(b, '0')
   473  	}
   474  
   475  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   476  	b = append(b, []byte{0x2d}...)
   477  	b = append(b, en.monthsAbbreviated[t.Month()]...)
   478  	b = append(b, []byte{0x2d}...)
   479  
   480  	if t.Year() > 0 {
   481  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   482  	} else {
   483  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   484  	}
   485  
   486  	return string(b)
   487  }
   488  
   489  // FmtDateLong returns the long date representation of 't' for 'en_IN'
   490  func (en *en_IN) FmtDateLong(t time.Time) string {
   491  
   492  	b := make([]byte, 0, 32)
   493  
   494  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   495  	b = append(b, []byte{0x20}...)
   496  	b = append(b, en.monthsWide[t.Month()]...)
   497  	b = append(b, []byte{0x20}...)
   498  
   499  	if t.Year() > 0 {
   500  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   501  	} else {
   502  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   503  	}
   504  
   505  	return string(b)
   506  }
   507  
   508  // FmtDateFull returns the full date representation of 't' for 'en_IN'
   509  func (en *en_IN) FmtDateFull(t time.Time) string {
   510  
   511  	b := make([]byte, 0, 32)
   512  
   513  	b = append(b, en.daysWide[t.Weekday()]...)
   514  	b = append(b, []byte{0x2c, 0x20}...)
   515  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   516  	b = append(b, []byte{0x20}...)
   517  	b = append(b, en.monthsWide[t.Month()]...)
   518  	b = append(b, []byte{0x2c, 0x20}...)
   519  
   520  	if t.Year() > 0 {
   521  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   522  	} else {
   523  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   524  	}
   525  
   526  	return string(b)
   527  }
   528  
   529  // FmtTimeShort returns the short time representation of 't' for 'en_IN'
   530  func (en *en_IN) FmtTimeShort(t time.Time) string {
   531  
   532  	b := make([]byte, 0, 32)
   533  
   534  	h := t.Hour()
   535  
   536  	if h > 12 {
   537  		h -= 12
   538  	}
   539  
   540  	b = strconv.AppendInt(b, int64(h), 10)
   541  	b = append(b, en.timeSeparator...)
   542  
   543  	if t.Minute() < 10 {
   544  		b = append(b, '0')
   545  	}
   546  
   547  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   548  	b = append(b, []byte{0x20}...)
   549  
   550  	if t.Hour() < 12 {
   551  		b = append(b, en.periodsAbbreviated[0]...)
   552  	} else {
   553  		b = append(b, en.periodsAbbreviated[1]...)
   554  	}
   555  
   556  	return string(b)
   557  }
   558  
   559  // FmtTimeMedium returns the medium time representation of 't' for 'en_IN'
   560  func (en *en_IN) FmtTimeMedium(t time.Time) string {
   561  
   562  	b := make([]byte, 0, 32)
   563  
   564  	h := t.Hour()
   565  
   566  	if h > 12 {
   567  		h -= 12
   568  	}
   569  
   570  	b = strconv.AppendInt(b, int64(h), 10)
   571  	b = append(b, en.timeSeparator...)
   572  
   573  	if t.Minute() < 10 {
   574  		b = append(b, '0')
   575  	}
   576  
   577  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   578  	b = append(b, en.timeSeparator...)
   579  
   580  	if t.Second() < 10 {
   581  		b = append(b, '0')
   582  	}
   583  
   584  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   585  	b = append(b, []byte{0x20}...)
   586  
   587  	if t.Hour() < 12 {
   588  		b = append(b, en.periodsAbbreviated[0]...)
   589  	} else {
   590  		b = append(b, en.periodsAbbreviated[1]...)
   591  	}
   592  
   593  	return string(b)
   594  }
   595  
   596  // FmtTimeLong returns the long time representation of 't' for 'en_IN'
   597  func (en *en_IN) FmtTimeLong(t time.Time) string {
   598  
   599  	b := make([]byte, 0, 32)
   600  
   601  	h := t.Hour()
   602  
   603  	if h > 12 {
   604  		h -= 12
   605  	}
   606  
   607  	b = strconv.AppendInt(b, int64(h), 10)
   608  	b = append(b, en.timeSeparator...)
   609  
   610  	if t.Minute() < 10 {
   611  		b = append(b, '0')
   612  	}
   613  
   614  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   615  	b = append(b, en.timeSeparator...)
   616  
   617  	if t.Second() < 10 {
   618  		b = append(b, '0')
   619  	}
   620  
   621  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   622  	b = append(b, []byte{0x20}...)
   623  
   624  	if t.Hour() < 12 {
   625  		b = append(b, en.periodsAbbreviated[0]...)
   626  	} else {
   627  		b = append(b, en.periodsAbbreviated[1]...)
   628  	}
   629  
   630  	b = append(b, []byte{0x20}...)
   631  
   632  	tz, _ := t.Zone()
   633  	b = append(b, tz...)
   634  
   635  	return string(b)
   636  }
   637  
   638  // FmtTimeFull returns the full time representation of 't' for 'en_IN'
   639  func (en *en_IN) FmtTimeFull(t time.Time) string {
   640  
   641  	b := make([]byte, 0, 32)
   642  
   643  	h := t.Hour()
   644  
   645  	if h > 12 {
   646  		h -= 12
   647  	}
   648  
   649  	b = strconv.AppendInt(b, int64(h), 10)
   650  	b = append(b, en.timeSeparator...)
   651  
   652  	if t.Minute() < 10 {
   653  		b = append(b, '0')
   654  	}
   655  
   656  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   657  	b = append(b, en.timeSeparator...)
   658  
   659  	if t.Second() < 10 {
   660  		b = append(b, '0')
   661  	}
   662  
   663  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   664  	b = append(b, []byte{0x20}...)
   665  
   666  	if t.Hour() < 12 {
   667  		b = append(b, en.periodsAbbreviated[0]...)
   668  	} else {
   669  		b = append(b, en.periodsAbbreviated[1]...)
   670  	}
   671  
   672  	b = append(b, []byte{0x20}...)
   673  
   674  	tz, _ := t.Zone()
   675  
   676  	if btz, ok := en.timezones[tz]; ok {
   677  		b = append(b, btz...)
   678  	} else {
   679  		b = append(b, tz...)
   680  	}
   681  
   682  	return string(b)
   683  }
   684  

View as plain text