...

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

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

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

View as plain text