...

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

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

     1  package af_NA
     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 af_NA 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 'af_NA' locale
    45  func New() locales.Translator {
    46  	return &af_NA{
    47  		locale:                 "af_NA",
    48  		pluralsCardinal:        []locales.PluralRule{2, 6},
    49  		pluralsOrdinal:         []locales.PluralRule{6},
    50  		pluralsRange:           []locales.PluralRule{6},
    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", "$", "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{"", "Jan.", "Feb.", "Mrt.", "Apr.", "Mei", "Jun.", "Jul.", "Aug.", "Sep.", "Okt.", "Nov.", "Des."},
    62  		monthsNarrow:           []string{"", "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"},
    63  		monthsWide:             []string{"", "Januarie", "Februarie", "Maart", "April", "Mei", "Junie", "Julie", "Augustus", "September", "Oktober", "November", "Desember"},
    64  		daysAbbreviated:        []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."},
    65  		daysNarrow:             []string{"S", "M", "D", "W", "D", "V", "S"},
    66  		daysShort:              []string{"So.", "Ma.", "Di.", "Wo.", "Do.", "Vr.", "Sa."},
    67  		daysWide:               []string{"Sondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrydag", "Saterdag"},
    68  		periodsAbbreviated:     []string{"vm.", "nm."},
    69  		periodsNarrow:          []string{"v", "n"},
    70  		periodsWide:            []string{"vm.", "nm."},
    71  		erasAbbreviated:        []string{"v.C.", "n.C."},
    72  		erasNarrow:             []string{"v.C.", "n.C."},
    73  		erasWide:               []string{"voor Christus", "na Christus"},
    74  		timezones:              map[string]string{"ACDT": "Sentraal-Australiese dagligtyd", "ACST": "Sentraal-Australiese standaardtyd", "ACWDT": "Sentraal-westelike Australiese dagligtyd", "ACWST": "Sentraal-westelike Australiese standaard-tyd", "ADT": "Atlantiese dagligtyd", "AEDT": "Oostelike Australiese dagligtyd", "AEST": "Oostelike Australiese standaardtyd", "AKDT": "Alaska-dagligtyd", "AKST": "Alaska-standaardtyd", "ARST": "Argentinië-somertyd", "ART": "Argentinië-standaardtyd", "AST": "Atlantiese standaardtyd", "AWDT": "Westelike Australiese dagligtyd", "AWST": "Westelike Australiese standaardtyd", "BOT": "Bolivia-tyd", "BT": "Bhoetan-tyd", "CAT": "Sentraal-Afrika-tyd", "CDT": "Noord-Amerikaanse sentrale dagligtyd", "CHADT": "Chatham-dagligtyd", "CHAST": "Chatham-standaardtyd", "CLST": "Chili-somertyd", "CLT": "Chili-standaardtyd", "COST": "Colombia-somertyd", "COT": "Colombië-standaardtyd", "CST": "Noord-Amerikaanse sentrale standaardtyd", "ChST": "Chamorro-standaardtyd", "EAT": "Oos-Afrika-tyd", "ECT": "Ecuador-tyd", "EDT": "Noord-Amerikaanse oostelike dagligtyd", "EST": "Noord-Amerikaanse oostelike standaardtyd", "GFT": "Frans-Guiana-tyd", "GMT": "Greenwich-tyd", "GST": "Persiese Golf-standaardtyd", "GYT": "Guyana-tyd", "HADT": "Hawaii-Aleoete-dagligtyd", "HAST": "Hawaii-Aleoete-standaardtyd", "HAT": "Newfoundland-dagligtyd", "HECU": "Kuba-dagligtyd", "HEEG": "Oos-Groenland-somertyd", "HENOMX": "Noordwes-Meksiko-dagligtyd", "HEOG": "Wes-Groenland-somertyd", "HEPM": "Sint-Pierre en Miquelon-dagligtyd", "HEPMX": "Meksikaanse Pasifiese dagligtyd", "HKST": "Hongkong-somertyd", "HKT": "Hongkong-standaardtyd", "HNCU": "Kuba-standaardtyd", "HNEG": "Oos-Groenland-standaardtyd", "HNNOMX": "Noordwes-Meksiko-standaardtyd", "HNOG": "Wes-Groenland-standaardtyd", "HNPM": "Sint-Pierre en Miquelon-standaardtyd", "HNPMX": "Meksikaanse Pasifiese standaardtyd", "HNT": "Newfoundland-standaardtyd", "IST": "Indië-standaardtyd", "JDT": "Japan-dagligtyd", "JST": "Japan-standaardtyd", "LHDT": "Lord Howe-dagligtyd", "LHST": "Lord Howe-standaardtyd", "MDT": "Noord-Amerikaanse berg-dagligtyd", "MESZ": "Sentraal-Europese somertyd", "MEZ": "Sentraal-Europese standaardtyd", "MST": "Noord-Amerikaanse berg-standaardtyd", "MYT": "Maleisië-tyd", "NZDT": "Nieu-Seeland-dagligtyd", "NZST": "Nieu-Seeland-standaardtyd", "OESZ": "Oos-Europese somertyd", "OEZ": "Oos-Europese standaardtyd", "PDT": "Pasifiese dagligtyd", "PST": "Pasifiese standaardtyd", "SAST": "Suid-Afrika-standaardtyd", "SGT": "Singapoer-standaardtyd", "SRT": "Suriname-tyd", "TMST": "Turkmenistan-somertyd", "TMT": "Turkmenistan-standaardtyd", "UYST": "Uruguay-somertyd", "UYT": "Uruguay-standaardtyd", "VET": "Venezuela-tyd", "WARST": "Wes-Argentinië-somertyd", "WART": "Wes-Argentinië-standaardtyd", "WAST": "Wes-Afrika-somertyd", "WAT": "Wes-Afrika-standaardtyd", "WESZ": "Wes-Europese somertyd", "WEZ": "Wes-Europese standaardtyd", "WIB": "Wes-Indonesië-tyd", "WIT": "Oos-Indonesië-tyd", "WITA": "Sentraal-Indonesiese tyd", "∅∅∅": "Asore-somertyd"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (af *af_NA) Locale() string {
    80  	return af.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'af_NA'
    84  func (af *af_NA) PluralsCardinal() []locales.PluralRule {
    85  	return af.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'af_NA'
    89  func (af *af_NA) PluralsOrdinal() []locales.PluralRule {
    90  	return af.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'af_NA'
    94  func (af *af_NA) PluralsRange() []locales.PluralRule {
    95  	return af.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'af_NA'
    99  func (af *af_NA) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  
   101  	n := math.Abs(num)
   102  
   103  	if n == 1 {
   104  		return locales.PluralRuleOne
   105  	}
   106  
   107  	return locales.PluralRuleOther
   108  }
   109  
   110  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'af_NA'
   111  func (af *af_NA) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   112  	return locales.PluralRuleOther
   113  }
   114  
   115  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'af_NA'
   116  func (af *af_NA) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   117  	return locales.PluralRuleOther
   118  }
   119  
   120  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   121  func (af *af_NA) MonthAbbreviated(month time.Month) string {
   122  	return af.monthsAbbreviated[month]
   123  }
   124  
   125  // MonthsAbbreviated returns the locales abbreviated months
   126  func (af *af_NA) MonthsAbbreviated() []string {
   127  	return af.monthsAbbreviated[1:]
   128  }
   129  
   130  // MonthNarrow returns the locales narrow month given the 'month' provided
   131  func (af *af_NA) MonthNarrow(month time.Month) string {
   132  	return af.monthsNarrow[month]
   133  }
   134  
   135  // MonthsNarrow returns the locales narrow months
   136  func (af *af_NA) MonthsNarrow() []string {
   137  	return af.monthsNarrow[1:]
   138  }
   139  
   140  // MonthWide returns the locales wide month given the 'month' provided
   141  func (af *af_NA) MonthWide(month time.Month) string {
   142  	return af.monthsWide[month]
   143  }
   144  
   145  // MonthsWide returns the locales wide months
   146  func (af *af_NA) MonthsWide() []string {
   147  	return af.monthsWide[1:]
   148  }
   149  
   150  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   151  func (af *af_NA) WeekdayAbbreviated(weekday time.Weekday) string {
   152  	return af.daysAbbreviated[weekday]
   153  }
   154  
   155  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   156  func (af *af_NA) WeekdaysAbbreviated() []string {
   157  	return af.daysAbbreviated
   158  }
   159  
   160  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   161  func (af *af_NA) WeekdayNarrow(weekday time.Weekday) string {
   162  	return af.daysNarrow[weekday]
   163  }
   164  
   165  // WeekdaysNarrow returns the locales narrow weekdays
   166  func (af *af_NA) WeekdaysNarrow() []string {
   167  	return af.daysNarrow
   168  }
   169  
   170  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   171  func (af *af_NA) WeekdayShort(weekday time.Weekday) string {
   172  	return af.daysShort[weekday]
   173  }
   174  
   175  // WeekdaysShort returns the locales short weekdays
   176  func (af *af_NA) WeekdaysShort() []string {
   177  	return af.daysShort
   178  }
   179  
   180  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   181  func (af *af_NA) WeekdayWide(weekday time.Weekday) string {
   182  	return af.daysWide[weekday]
   183  }
   184  
   185  // WeekdaysWide returns the locales wide weekdays
   186  func (af *af_NA) WeekdaysWide() []string {
   187  	return af.daysWide
   188  }
   189  
   190  // Decimal returns the decimal point of number
   191  func (af *af_NA) Decimal() string {
   192  	return af.decimal
   193  }
   194  
   195  // Group returns the group of number
   196  func (af *af_NA) Group() string {
   197  	return af.group
   198  }
   199  
   200  // Group returns the minus sign of number
   201  func (af *af_NA) Minus() string {
   202  	return af.minus
   203  }
   204  
   205  // FmtNumber returns 'num' with digits/precision of 'v' for 'af_NA' and handles both Whole and Real numbers based on 'v'
   206  func (af *af_NA) FmtNumber(num float64, v uint64) string {
   207  
   208  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   209  	l := len(s) + 2 + 2*len(s[:len(s)-int(v)-1])/3
   210  	count := 0
   211  	inWhole := v == 0
   212  	b := make([]byte, 0, l)
   213  
   214  	for i := len(s) - 1; i >= 0; i-- {
   215  
   216  		if s[i] == '.' {
   217  			b = append(b, af.decimal[0])
   218  			inWhole = true
   219  			continue
   220  		}
   221  
   222  		if inWhole {
   223  			if count == 3 {
   224  				for j := len(af.group) - 1; j >= 0; j-- {
   225  					b = append(b, af.group[j])
   226  				}
   227  				count = 1
   228  			} else {
   229  				count++
   230  			}
   231  		}
   232  
   233  		b = append(b, s[i])
   234  	}
   235  
   236  	if num < 0 {
   237  		b = append(b, af.minus[0])
   238  	}
   239  
   240  	// reverse
   241  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   242  		b[i], b[j] = b[j], b[i]
   243  	}
   244  
   245  	return string(b)
   246  }
   247  
   248  // FmtPercent returns 'num' with digits/precision of 'v' for 'af_NA' and handles both Whole and Real numbers based on 'v'
   249  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   250  func (af *af_NA) FmtPercent(num float64, v uint64) string {
   251  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   252  	l := len(s) + 3
   253  	b := make([]byte, 0, l)
   254  
   255  	for i := len(s) - 1; i >= 0; i-- {
   256  
   257  		if s[i] == '.' {
   258  			b = append(b, af.decimal[0])
   259  			continue
   260  		}
   261  
   262  		b = append(b, s[i])
   263  	}
   264  
   265  	if num < 0 {
   266  		b = append(b, af.minus[0])
   267  	}
   268  
   269  	// reverse
   270  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   271  		b[i], b[j] = b[j], b[i]
   272  	}
   273  
   274  	b = append(b, af.percent...)
   275  
   276  	return string(b)
   277  }
   278  
   279  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'af_NA'
   280  func (af *af_NA) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   281  
   282  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   283  	symbol := af.currencies[currency]
   284  	l := len(s) + len(symbol) + 2 + 2*len(s[:len(s)-int(v)-1])/3
   285  	count := 0
   286  	inWhole := v == 0
   287  	b := make([]byte, 0, l)
   288  
   289  	for i := len(s) - 1; i >= 0; i-- {
   290  
   291  		if s[i] == '.' {
   292  			b = append(b, af.decimal[0])
   293  			inWhole = true
   294  			continue
   295  		}
   296  
   297  		if inWhole {
   298  			if count == 3 {
   299  				for j := len(af.group) - 1; j >= 0; j-- {
   300  					b = append(b, af.group[j])
   301  				}
   302  				count = 1
   303  			} else {
   304  				count++
   305  			}
   306  		}
   307  
   308  		b = append(b, s[i])
   309  	}
   310  
   311  	for j := len(symbol) - 1; j >= 0; j-- {
   312  		b = append(b, symbol[j])
   313  	}
   314  
   315  	if num < 0 {
   316  		b = append(b, af.minus[0])
   317  	}
   318  
   319  	// reverse
   320  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   321  		b[i], b[j] = b[j], b[i]
   322  	}
   323  
   324  	if int(v) < 2 {
   325  
   326  		if v == 0 {
   327  			b = append(b, af.decimal...)
   328  		}
   329  
   330  		for i := 0; i < 2-int(v); i++ {
   331  			b = append(b, '0')
   332  		}
   333  	}
   334  
   335  	return string(b)
   336  }
   337  
   338  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'af_NA'
   339  // in accounting notation.
   340  func (af *af_NA) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   341  
   342  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   343  	symbol := af.currencies[currency]
   344  	l := len(s) + len(symbol) + 4 + 2*len(s[:len(s)-int(v)-1])/3
   345  	count := 0
   346  	inWhole := v == 0
   347  	b := make([]byte, 0, l)
   348  
   349  	for i := len(s) - 1; i >= 0; i-- {
   350  
   351  		if s[i] == '.' {
   352  			b = append(b, af.decimal[0])
   353  			inWhole = true
   354  			continue
   355  		}
   356  
   357  		if inWhole {
   358  			if count == 3 {
   359  				for j := len(af.group) - 1; j >= 0; j-- {
   360  					b = append(b, af.group[j])
   361  				}
   362  				count = 1
   363  			} else {
   364  				count++
   365  			}
   366  		}
   367  
   368  		b = append(b, s[i])
   369  	}
   370  
   371  	if num < 0 {
   372  
   373  		for j := len(symbol) - 1; j >= 0; j-- {
   374  			b = append(b, symbol[j])
   375  		}
   376  
   377  		b = append(b, af.currencyNegativePrefix[0])
   378  
   379  	} else {
   380  
   381  		for j := len(symbol) - 1; j >= 0; j-- {
   382  			b = append(b, symbol[j])
   383  		}
   384  
   385  	}
   386  
   387  	// reverse
   388  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   389  		b[i], b[j] = b[j], b[i]
   390  	}
   391  
   392  	if int(v) < 2 {
   393  
   394  		if v == 0 {
   395  			b = append(b, af.decimal...)
   396  		}
   397  
   398  		for i := 0; i < 2-int(v); i++ {
   399  			b = append(b, '0')
   400  		}
   401  	}
   402  
   403  	if num < 0 {
   404  		b = append(b, af.currencyNegativeSuffix...)
   405  	}
   406  
   407  	return string(b)
   408  }
   409  
   410  // FmtDateShort returns the short date representation of 't' for 'af_NA'
   411  func (af *af_NA) FmtDateShort(t time.Time) string {
   412  
   413  	b := make([]byte, 0, 32)
   414  
   415  	if t.Year() > 0 {
   416  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   417  	} else {
   418  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   419  	}
   420  
   421  	b = append(b, []byte{0x2d}...)
   422  
   423  	if t.Month() < 10 {
   424  		b = append(b, '0')
   425  	}
   426  
   427  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   428  
   429  	b = append(b, []byte{0x2d}...)
   430  
   431  	if t.Day() < 10 {
   432  		b = append(b, '0')
   433  	}
   434  
   435  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   436  
   437  	return string(b)
   438  }
   439  
   440  // FmtDateMedium returns the medium date representation of 't' for 'af_NA'
   441  func (af *af_NA) FmtDateMedium(t time.Time) string {
   442  
   443  	b := make([]byte, 0, 32)
   444  
   445  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   446  	b = append(b, []byte{0x20}...)
   447  	b = append(b, af.monthsAbbreviated[t.Month()]...)
   448  	b = append(b, []byte{0x20}...)
   449  
   450  	if t.Year() > 0 {
   451  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   452  	} else {
   453  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   454  	}
   455  
   456  	return string(b)
   457  }
   458  
   459  // FmtDateLong returns the long date representation of 't' for 'af_NA'
   460  func (af *af_NA) FmtDateLong(t time.Time) string {
   461  
   462  	b := make([]byte, 0, 32)
   463  
   464  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   465  	b = append(b, []byte{0x20}...)
   466  	b = append(b, af.monthsWide[t.Month()]...)
   467  	b = append(b, []byte{0x20}...)
   468  
   469  	if t.Year() > 0 {
   470  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   471  	} else {
   472  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   473  	}
   474  
   475  	return string(b)
   476  }
   477  
   478  // FmtDateFull returns the full date representation of 't' for 'af_NA'
   479  func (af *af_NA) FmtDateFull(t time.Time) string {
   480  
   481  	b := make([]byte, 0, 32)
   482  
   483  	b = append(b, af.daysWide[t.Weekday()]...)
   484  	b = append(b, []byte{0x20}...)
   485  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   486  	b = append(b, []byte{0x20}...)
   487  	b = append(b, af.monthsWide[t.Month()]...)
   488  	b = append(b, []byte{0x20}...)
   489  
   490  	if t.Year() > 0 {
   491  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   492  	} else {
   493  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   494  	}
   495  
   496  	return string(b)
   497  }
   498  
   499  // FmtTimeShort returns the short time representation of 't' for 'af_NA'
   500  func (af *af_NA) FmtTimeShort(t time.Time) string {
   501  
   502  	b := make([]byte, 0, 32)
   503  
   504  	h := t.Hour()
   505  
   506  	if h > 12 {
   507  		h -= 12
   508  	}
   509  
   510  	b = strconv.AppendInt(b, int64(h), 10)
   511  	b = append(b, af.timeSeparator...)
   512  
   513  	if t.Minute() < 10 {
   514  		b = append(b, '0')
   515  	}
   516  
   517  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   518  	b = append(b, []byte{0x20}...)
   519  
   520  	if t.Hour() < 12 {
   521  		b = append(b, af.periodsAbbreviated[0]...)
   522  	} else {
   523  		b = append(b, af.periodsAbbreviated[1]...)
   524  	}
   525  
   526  	return string(b)
   527  }
   528  
   529  // FmtTimeMedium returns the medium time representation of 't' for 'af_NA'
   530  func (af *af_NA) FmtTimeMedium(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, af.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, af.timeSeparator...)
   549  
   550  	if t.Second() < 10 {
   551  		b = append(b, '0')
   552  	}
   553  
   554  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   555  	b = append(b, []byte{0x20}...)
   556  
   557  	if t.Hour() < 12 {
   558  		b = append(b, af.periodsAbbreviated[0]...)
   559  	} else {
   560  		b = append(b, af.periodsAbbreviated[1]...)
   561  	}
   562  
   563  	return string(b)
   564  }
   565  
   566  // FmtTimeLong returns the long time representation of 't' for 'af_NA'
   567  func (af *af_NA) FmtTimeLong(t time.Time) string {
   568  
   569  	b := make([]byte, 0, 32)
   570  
   571  	h := t.Hour()
   572  
   573  	if h > 12 {
   574  		h -= 12
   575  	}
   576  
   577  	b = strconv.AppendInt(b, int64(h), 10)
   578  	b = append(b, af.timeSeparator...)
   579  
   580  	if t.Minute() < 10 {
   581  		b = append(b, '0')
   582  	}
   583  
   584  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   585  	b = append(b, af.timeSeparator...)
   586  
   587  	if t.Second() < 10 {
   588  		b = append(b, '0')
   589  	}
   590  
   591  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   592  	b = append(b, []byte{0x20}...)
   593  
   594  	if t.Hour() < 12 {
   595  		b = append(b, af.periodsAbbreviated[0]...)
   596  	} else {
   597  		b = append(b, af.periodsAbbreviated[1]...)
   598  	}
   599  
   600  	b = append(b, []byte{0x20}...)
   601  
   602  	tz, _ := t.Zone()
   603  	b = append(b, tz...)
   604  
   605  	return string(b)
   606  }
   607  
   608  // FmtTimeFull returns the full time representation of 't' for 'af_NA'
   609  func (af *af_NA) FmtTimeFull(t time.Time) string {
   610  
   611  	b := make([]byte, 0, 32)
   612  
   613  	h := t.Hour()
   614  
   615  	if h > 12 {
   616  		h -= 12
   617  	}
   618  
   619  	b = strconv.AppendInt(b, int64(h), 10)
   620  	b = append(b, af.timeSeparator...)
   621  
   622  	if t.Minute() < 10 {
   623  		b = append(b, '0')
   624  	}
   625  
   626  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   627  	b = append(b, af.timeSeparator...)
   628  
   629  	if t.Second() < 10 {
   630  		b = append(b, '0')
   631  	}
   632  
   633  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   634  	b = append(b, []byte{0x20}...)
   635  
   636  	if t.Hour() < 12 {
   637  		b = append(b, af.periodsAbbreviated[0]...)
   638  	} else {
   639  		b = append(b, af.periodsAbbreviated[1]...)
   640  	}
   641  
   642  	b = append(b, []byte{0x20}...)
   643  
   644  	tz, _ := t.Zone()
   645  
   646  	if btz, ok := af.timezones[tz]; ok {
   647  		b = append(b, btz...)
   648  	} else {
   649  		b = append(b, tz...)
   650  	}
   651  
   652  	return string(b)
   653  }
   654  

View as plain text