1package pa
2
3import (
4	"math"
5	"strconv"
6	"time"
7
8	"github.com/gohugoio/locales"
9	"github.com/gohugoio/locales/currency"
10)
11
12type pa 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 'pa' locale
43func New() locales.Translator {
44	return &pa{
45		locale:             "pa",
46		pluralsCardinal:    []locales.PluralRule{2, 6},
47		pluralsOrdinal:     []locales.PluralRule{6},
48		pluralsRange:       []locales.PluralRule{2, 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", "A$", "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", "R$", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CA$", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CN¥", "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", "€", "FIM", "FJD", "FKP", "FRF", "£", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HK$", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "₪", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "₩", "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", "MX$", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZ$", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "р.", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "STN", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VEF", "VES", "₫", "VNN", "VUV", "WST", "FCFA", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "EC$", "XDR", "XEU", "XFO", "XFU", "CFA", "XPD", "CFPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWL", "ZWR"},
57		monthsAbbreviated:  []string{"", "ਜਨ", "ਫ਼ਰ", "ਮਾਰਚ", "ਅਪ੍ਰੈ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾ", "ਅਗ", "ਸਤੰ", "ਅਕਤੂ", "ਨਵੰ", "ਦਸੰ"},
58		monthsNarrow:       []string{"", "ਜ", "ਫ਼", "ਮਾ", "ਅ", "ਮ", "ਜੂ", "ਜੁ", "ਅ", "ਸ", "ਅ", "ਨ", "ਦ"},
59		monthsWide:         []string{"", "ਜਨਵਰੀ", "ਫ਼ਰਵਰੀ", "ਮਾਰਚ", "ਅਪ੍ਰੈਲ", "ਮਈ", "ਜੂਨ", "ਜੁਲਾਈ", "ਅਗਸਤ", "ਸਤੰਬਰ", "ਅਕਤੂਬਰ", "ਨਵੰਬਰ", "ਦਸੰਬਰ"},
60		daysAbbreviated:    []string{"ਐਤ", "ਸੋਮ", "ਮੰਗਲ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕਰ", "ਸ਼ਨਿੱਚਰ"},
61		daysNarrow:         []string{"ਐ", "ਸੋ", "ਮੰ", "ਬੁੱ", "ਵੀ", "ਸ਼ੁੱ", "ਸ਼"},
62		daysShort:          []string{"ਐਤ", "ਸੋਮ", "ਮੰਗ", "ਬੁੱਧ", "ਵੀਰ", "ਸ਼ੁੱਕ", "ਸ਼ਨਿੱ"},
63		daysWide:           []string{"ਐਤਵਾਰ", "ਸੋਮਵਾਰ", "ਮੰਗਲਵਾਰ", "ਬੁੱਧਵਾਰ", "ਵੀਰਵਾਰ", "ਸ਼ੁੱਕਰਵਾਰ", "ਸ਼ਨਿੱਚਰਵਾਰ"},
64		periodsAbbreviated: []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."},
65		periodsNarrow:      []string{"ਸ.", "ਸ਼."},
66		periodsWide:        []string{"ਪੂ.ਦੁ.", "ਬਾ.ਦੁ."},
67		erasAbbreviated:    []string{"ਈ. ਪੂ.", "ਸੰਨ"},
68		erasNarrow:         []string{"ਈ.ਪੂ.", "ਸੰਨ"},
69		erasWide:           []string{"ਈਸਵੀ ਪੂਰਵ", "ਈਸਵੀ ਸੰਨ"},
70		timezones:          map[string]string{"ACDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "ACWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "ACWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਕੇਂਦਰੀ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "ADT": "ਅਟਲਾਂਟਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AEDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AEST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "AKDT": "ਅਲਾਸਕਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AKST": "ਅਲਾਸਕਾ ਮਿਆਰੀ ਵੇਲਾ", "ARST": "ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "ART": "ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "AST": "ਅਟਲਾਂਟਿਕ ਮਿਆਰੀ ਵੇਲਾ", "AWDT": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "AWST": "ਆਸਟ੍ਰੇਲੀਆਈ ਪੱਛਮੀ ਮਿਆਰੀ ਵੇਲਾ", "BOT": "ਬੋਲੀਵੀਆ ਵੇਲਾ", "BT": "ਭੂਟਾਨ ਵੇਲਾ", "CAT": "ਕੇਂਦਰੀ ਅਫਰੀਕਾ ਵੇਲਾ", "CDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CHADT": "ਚੈਥਮ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "CHAST": "ਚੈਥਮ ਮਿਆਰੀ ਵੇਲਾ", "CLST": "ਚਿਲੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "CLT": "ਚਿਲੀ ਮਿਆਰੀ ਵੇਲਾ", "COST": "ਕੋਲੰਬੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "COT": "ਕੋਲੰਬੀਆ ਮਿਆਰੀ ਵੇਲਾ", "CST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਕੇਂਦਰੀ ਮਿਆਰੀ ਵੇਲਾ", "ChST": "ਚਾਮੋਰੋ ਮਿਆਰੀ ਵੇਲਾ", "EAT": "ਪੂਰਬੀ ਅਫਰੀਕਾ ਵੇਲਾ", "ECT": "ਇਕਵੇਡੋਰ ਵੇਲਾ", "EDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "EST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੂਰਬੀ ਮਿਆਰੀ ਵੇਲਾ", "GFT": "ਫ੍ਰੈਂਚ ਗੁਏਨਾ ਵੇਲਾ", "GMT": "ਗ੍ਰੀਨਵਿਚ ਮੀਨ ਵੇਲਾ", "GST": "ਖਾੜੀ ਮਿਆਰੀ ਵੇਲਾ", "GYT": "ਗੁਯਾਨਾ ਵੇਲਾ", "HADT": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HAST": "ਹਵਾਈ-ਅਲੇਯੂਸ਼ਿਅਨ ਮਿਆਰੀ ਵੇਲਾ", "HAT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HECU": "ਕਿਊਬਾ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HEEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HENOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HEOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HEPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HEPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "HKST": "ਹਾਂਗ ਕਾਂਗ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "HKT": "ਹਾਂਗ ਕਾਂਗ ਮਿਆਰੀ ਵੇਲਾ", "HNCU": "ਕਿਊਬਾ ਮਿਆਰੀ ਵੇਲਾ", "HNEG": "ਪੂਰਬੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "HNNOMX": "ਉੱਤਰ ਪੱਛਮੀ ਮੈਕਸੀਕੋ ਮਿਆਰੀ ਵੇਲਾ", "HNOG": "ਪੱਛਮੀ ਗ੍ਰੀਨਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "HNPM": "ਸੈਂਟ ਪੀਅਰੇ ਅਤੇ ਮਿਕੇਲਨ ਮਿਆਰੀ ਵੇਲਾ", "HNPMX": "ਮੈਕਸੀਕਨ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "HNT": "ਨਿਊਫਾਉਂਡਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "IST": "ਭਾਰਤੀ ਮਿਆਰੀ ਵੇਲਾ", "JDT": "ਜਪਾਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "JST": "ਜਪਾਨ ਮਿਆਰੀ ਵੇਲਾ", "LHDT": "ਲੌਰਡ ਹੋਵੇ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "LHST": "ਲੌਰਡ ਹੋਵੇ ਮਿਆਰੀ ਵੇਲਾ", "MDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਮਾਉਂਟੇਨ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "MESZ": "ਮੱਧ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "MEZ": "ਮੱਧ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "MST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਮਾਉਂਟੇਨ ਮਿਆਰੀ ਵੇਲਾ", "MYT": "ਮਲੇਸ਼ੀਆ ਵੇਲਾ", "NZDT": "ਨਿਊਜ਼ੀਲੈਂਡ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "NZST": "ਨਿਊਜ਼ੀਲੈਂਡ ਮਿਆਰੀ ਵੇਲਾ", "OESZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "OEZ": "ਪੂਰਬੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "PDT": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਪ੍ਰਕਾਸ਼ ਵੇਲਾ", "PST": "ਉੱਤਰੀ ਅਮਰੀਕੀ ਪੈਸਿਫਿਕ ਮਿਆਰੀ ਵੇਲਾ", "SAST": "ਦੱਖਣੀ ਅਫ਼ਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "SGT": "ਸਿੰਗਾਪੁਰ ਮਿਆਰੀ ਵੇਲਾ", "SRT": "ਸੂਰੀਨਾਮ ਵੇਲਾ", "TMST": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "TMT": "ਤੁਰਕਮੇਨਿਸਤਾਨ ਮਿਆਰੀ ਵੇਲਾ", "UYST": "ਉਰੂਗਵੇ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "UYT": "ਉਰੂਗਵੇ ਮਿਆਰੀ ਵੇਲਾ", "VET": "ਵੈਨੇਜ਼ੂਏਲਾ ਵੇਲਾ", "WARST": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WART": "ਪੱਛਮੀ ਅਰਜਨਟੀਨਾ ਮਿਆਰੀ ਵੇਲਾ", "WAST": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WAT": "ਪੱਛਮੀ ਅਫਰੀਕਾ ਮਿਆਰੀ ਵੇਲਾ", "WESZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ", "WEZ": "ਪੱਛਮੀ ਯੂਰਪੀ ਮਿਆਰੀ ਵੇਲਾ", "WIB": "ਪੱਛਮੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "WIT": "ਪੂਰਬੀ ਇੰਡੋਨੇਸ਼ੀਆ ਵੇਲਾ", "WITA": "ਮੱਧ ਇੰਡੋਨੇਸ਼ੀਆਈ ਵੇਲਾ", "∅∅∅": "ਬ੍ਰਾਜ਼ੀਲੀਆ ਗਰਮੀਆਂ ਦਾ ਵੇਲਾ"},
71	}
72}
73
74// Locale returns the current translators string locale
75func (pa *pa) Locale() string {
76	return pa.locale
77}
78
79// PluralsCardinal returns the list of cardinal plural rules associated with 'pa'
80func (pa *pa) PluralsCardinal() []locales.PluralRule {
81	return pa.pluralsCardinal
82}
83
84// PluralsOrdinal returns the list of ordinal plural rules associated with 'pa'
85func (pa *pa) PluralsOrdinal() []locales.PluralRule {
86	return pa.pluralsOrdinal
87}
88
89// PluralsRange returns the list of range plural rules associated with 'pa'
90func (pa *pa) PluralsRange() []locales.PluralRule {
91	return pa.pluralsRange
92}
93
94// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'pa'
95func (pa *pa) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
96
97	n := math.Abs(num)
98
99	if n >= 0 && n <= 1 {
100		return locales.PluralRuleOne
101	}
102
103	return locales.PluralRuleOther
104}
105
106// OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'pa'
107func (pa *pa) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
108	return locales.PluralRuleOther
109}
110
111// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'pa'
112func (pa *pa) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
113
114	start := pa.CardinalPluralRule(num1, v1)
115	end := pa.CardinalPluralRule(num2, v2)
116
117	if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
118		return locales.PluralRuleOne
119	} else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
120		return locales.PluralRuleOther
121	} else if start == locales.PluralRuleOther && end == locales.PluralRuleOne {
122		return locales.PluralRuleOne
123	}
124
125	return locales.PluralRuleOther
126
127}
128
129// MonthAbbreviated returns the locales abbreviated month given the 'month' provided
130func (pa *pa) MonthAbbreviated(month time.Month) string {
131	return pa.monthsAbbreviated[month]
132}
133
134// MonthsAbbreviated returns the locales abbreviated months
135func (pa *pa) MonthsAbbreviated() []string {
136	return pa.monthsAbbreviated[1:]
137}
138
139// MonthNarrow returns the locales narrow month given the 'month' provided
140func (pa *pa) MonthNarrow(month time.Month) string {
141	return pa.monthsNarrow[month]
142}
143
144// MonthsNarrow returns the locales narrow months
145func (pa *pa) MonthsNarrow() []string {
146	return pa.monthsNarrow[1:]
147}
148
149// MonthWide returns the locales wide month given the 'month' provided
150func (pa *pa) MonthWide(month time.Month) string {
151	return pa.monthsWide[month]
152}
153
154// MonthsWide returns the locales wide months
155func (pa *pa) MonthsWide() []string {
156	return pa.monthsWide[1:]
157}
158
159// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
160func (pa *pa) WeekdayAbbreviated(weekday time.Weekday) string {
161	return pa.daysAbbreviated[weekday]
162}
163
164// WeekdaysAbbreviated returns the locales abbreviated weekdays
165func (pa *pa) WeekdaysAbbreviated() []string {
166	return pa.daysAbbreviated
167}
168
169// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
170func (pa *pa) WeekdayNarrow(weekday time.Weekday) string {
171	return pa.daysNarrow[weekday]
172}
173
174// WeekdaysNarrow returns the locales narrow weekdays
175func (pa *pa) WeekdaysNarrow() []string {
176	return pa.daysNarrow
177}
178
179// WeekdayShort returns the locales short weekday given the 'weekday' provided
180func (pa *pa) WeekdayShort(weekday time.Weekday) string {
181	return pa.daysShort[weekday]
182}
183
184// WeekdaysShort returns the locales short weekdays
185func (pa *pa) WeekdaysShort() []string {
186	return pa.daysShort
187}
188
189// WeekdayWide returns the locales wide weekday given the 'weekday' provided
190func (pa *pa) WeekdayWide(weekday time.Weekday) string {
191	return pa.daysWide[weekday]
192}
193
194// WeekdaysWide returns the locales wide weekdays
195func (pa *pa) WeekdaysWide() []string {
196	return pa.daysWide
197}
198
199// Decimal returns the decimal point of number
200func (pa *pa) Decimal() string {
201	return pa.decimal
202}
203
204// Group returns the group of number
205func (pa *pa) Group() string {
206	return pa.group
207}
208
209// Group returns the minus sign of number
210func (pa *pa) Minus() string {
211	return pa.minus
212}
213
214// FmtNumber returns 'num' with digits/precision of 'v' for 'pa' and handles both Whole and Real numbers based on 'v'
215func (pa *pa) FmtNumber(num float64, v uint64) string {
216
217	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
218	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
219	count := 0
220	inWhole := v == 0
221	inSecondary := false
222	groupThreshold := 3
223
224	b := make([]byte, 0, l)
225
226	for i := len(s) - 1; i >= 0; i-- {
227
228		if s[i] == '.' {
229			b = append(b, pa.decimal[0])
230			inWhole = true
231			continue
232		}
233
234		if inWhole {
235
236			if count == groupThreshold {
237				b = append(b, pa.group[0])
238				count = 1
239
240				if !inSecondary {
241					inSecondary = true
242					groupThreshold = 2
243				}
244			} else {
245				count++
246			}
247		}
248
249		b = append(b, s[i])
250	}
251
252	if num < 0 {
253		b = append(b, pa.minus[0])
254	}
255
256	// reverse
257	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
258		b[i], b[j] = b[j], b[i]
259	}
260
261	return string(b)
262}
263
264// FmtPercent returns 'num' with digits/precision of 'v' for 'pa' and handles both Whole and Real numbers based on 'v'
265// NOTE: 'num' passed into FmtPercent is assumed to be in percent already
266func (pa *pa) FmtPercent(num float64, v uint64) string {
267	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
268	l := len(s) + 3
269	b := make([]byte, 0, l)
270
271	for i := len(s) - 1; i >= 0; i-- {
272
273		if s[i] == '.' {
274			b = append(b, pa.decimal[0])
275			continue
276		}
277
278		b = append(b, s[i])
279	}
280
281	if num < 0 {
282		b = append(b, pa.minus[0])
283	}
284
285	// reverse
286	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
287		b[i], b[j] = b[j], b[i]
288	}
289
290	b = append(b, pa.percent...)
291
292	return string(b)
293}
294
295// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'pa'
296func (pa *pa) FmtCurrency(num float64, v uint64, currency currency.Type) string {
297
298	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
299	symbol := pa.currencies[currency]
300	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
301	count := 0
302	inWhole := v == 0
303	inSecondary := false
304	groupThreshold := 3
305
306	b := make([]byte, 0, l)
307
308	for i := len(s) - 1; i >= 0; i-- {
309
310		if s[i] == '.' {
311			b = append(b, pa.decimal[0])
312			inWhole = true
313			continue
314		}
315
316		if inWhole {
317
318			if count == groupThreshold {
319				b = append(b, pa.group[0])
320				count = 1
321
322				if !inSecondary {
323					inSecondary = true
324					groupThreshold = 2
325				}
326			} else {
327				count++
328			}
329		}
330
331		b = append(b, s[i])
332	}
333
334	for j := len(symbol) - 1; j >= 0; j-- {
335		b = append(b, symbol[j])
336	}
337
338	if num < 0 {
339		b = append(b, pa.minus[0])
340	}
341
342	// reverse
343	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
344		b[i], b[j] = b[j], b[i]
345	}
346
347	if int(v) < 2 {
348
349		if v == 0 {
350			b = append(b, pa.decimal...)
351		}
352
353		for i := 0; i < 2-int(v); i++ {
354			b = append(b, '0')
355		}
356	}
357
358	return string(b)
359}
360
361// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'pa'
362// in accounting notation.
363func (pa *pa) FmtAccounting(num float64, v uint64, currency currency.Type) string {
364
365	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
366	symbol := pa.currencies[currency]
367	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
368	count := 0
369	inWhole := v == 0
370	inSecondary := false
371	groupThreshold := 3
372
373	b := make([]byte, 0, l)
374
375	for i := len(s) - 1; i >= 0; i-- {
376
377		if s[i] == '.' {
378			b = append(b, pa.decimal[0])
379			inWhole = true
380			continue
381		}
382
383		if inWhole {
384
385			if count == groupThreshold {
386				b = append(b, pa.group[0])
387				count = 1
388
389				if !inSecondary {
390					inSecondary = true
391					groupThreshold = 2
392				}
393			} else {
394				count++
395			}
396		}
397
398		b = append(b, s[i])
399	}
400
401	if num < 0 {
402
403		for j := len(symbol) - 1; j >= 0; j-- {
404			b = append(b, symbol[j])
405		}
406
407		b = append(b, pa.minus[0])
408
409	} else {
410
411		for j := len(symbol) - 1; j >= 0; j-- {
412			b = append(b, symbol[j])
413		}
414
415	}
416
417	// reverse
418	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
419		b[i], b[j] = b[j], b[i]
420	}
421
422	if int(v) < 2 {
423
424		if v == 0 {
425			b = append(b, pa.decimal...)
426		}
427
428		for i := 0; i < 2-int(v); i++ {
429			b = append(b, '0')
430		}
431	}
432
433	return string(b)
434}
435
436// FmtDateShort returns the short date representation of 't' for 'pa'
437func (pa *pa) FmtDateShort(t time.Time) string {
438
439	b := make([]byte, 0, 32)
440
441	b = strconv.AppendInt(b, int64(t.Day()), 10)
442	b = append(b, []byte{0x2f}...)
443	b = strconv.AppendInt(b, int64(t.Month()), 10)
444	b = append(b, []byte{0x2f}...)
445
446	if t.Year() > 9 {
447		b = append(b, strconv.Itoa(t.Year())[2:]...)
448	} else {
449		b = append(b, strconv.Itoa(t.Year())[1:]...)
450	}
451
452	return string(b)
453}
454
455// FmtDateMedium returns the medium date representation of 't' for 'pa'
456func (pa *pa) FmtDateMedium(t time.Time) string {
457
458	b := make([]byte, 0, 32)
459
460	b = strconv.AppendInt(b, int64(t.Day()), 10)
461	b = append(b, []byte{0x20}...)
462	b = append(b, pa.monthsAbbreviated[t.Month()]...)
463	b = append(b, []byte{0x20}...)
464
465	if t.Year() > 0 {
466		b = strconv.AppendInt(b, int64(t.Year()), 10)
467	} else {
468		b = strconv.AppendInt(b, int64(-t.Year()), 10)
469	}
470
471	return string(b)
472}
473
474// FmtDateLong returns the long date representation of 't' for 'pa'
475func (pa *pa) FmtDateLong(t time.Time) string {
476
477	b := make([]byte, 0, 32)
478
479	b = strconv.AppendInt(b, int64(t.Day()), 10)
480	b = append(b, []byte{0x20}...)
481	b = append(b, pa.monthsWide[t.Month()]...)
482	b = append(b, []byte{0x20}...)
483
484	if t.Year() > 0 {
485		b = strconv.AppendInt(b, int64(t.Year()), 10)
486	} else {
487		b = strconv.AppendInt(b, int64(-t.Year()), 10)
488	}
489
490	return string(b)
491}
492
493// FmtDateFull returns the full date representation of 't' for 'pa'
494func (pa *pa) FmtDateFull(t time.Time) string {
495
496	b := make([]byte, 0, 32)
497
498	b = append(b, pa.daysWide[t.Weekday()]...)
499	b = append(b, []byte{0x2c, 0x20}...)
500	b = strconv.AppendInt(b, int64(t.Day()), 10)
501	b = append(b, []byte{0x20}...)
502	b = append(b, pa.monthsWide[t.Month()]...)
503	b = append(b, []byte{0x20}...)
504
505	if t.Year() > 0 {
506		b = strconv.AppendInt(b, int64(t.Year()), 10)
507	} else {
508		b = strconv.AppendInt(b, int64(-t.Year()), 10)
509	}
510
511	return string(b)
512}
513
514// FmtTimeShort returns the short time representation of 't' for 'pa'
515func (pa *pa) FmtTimeShort(t time.Time) string {
516
517	b := make([]byte, 0, 32)
518
519	h := t.Hour()
520
521	if h > 12 {
522		h -= 12
523	}
524
525	b = strconv.AppendInt(b, int64(h), 10)
526	b = append(b, pa.timeSeparator...)
527
528	if t.Minute() < 10 {
529		b = append(b, '0')
530	}
531
532	b = strconv.AppendInt(b, int64(t.Minute()), 10)
533	b = append(b, []byte{0x20}...)
534
535	if t.Hour() < 12 {
536		b = append(b, pa.periodsAbbreviated[0]...)
537	} else {
538		b = append(b, pa.periodsAbbreviated[1]...)
539	}
540
541	return string(b)
542}
543
544// FmtTimeMedium returns the medium time representation of 't' for 'pa'
545func (pa *pa) FmtTimeMedium(t time.Time) string {
546
547	b := make([]byte, 0, 32)
548
549	h := t.Hour()
550
551	if h > 12 {
552		h -= 12
553	}
554
555	b = strconv.AppendInt(b, int64(h), 10)
556	b = append(b, pa.timeSeparator...)
557
558	if t.Minute() < 10 {
559		b = append(b, '0')
560	}
561
562	b = strconv.AppendInt(b, int64(t.Minute()), 10)
563	b = append(b, pa.timeSeparator...)
564
565	if t.Second() < 10 {
566		b = append(b, '0')
567	}
568
569	b = strconv.AppendInt(b, int64(t.Second()), 10)
570	b = append(b, []byte{0x20}...)
571
572	if t.Hour() < 12 {
573		b = append(b, pa.periodsAbbreviated[0]...)
574	} else {
575		b = append(b, pa.periodsAbbreviated[1]...)
576	}
577
578	return string(b)
579}
580
581// FmtTimeLong returns the long time representation of 't' for 'pa'
582func (pa *pa) FmtTimeLong(t time.Time) string {
583
584	b := make([]byte, 0, 32)
585
586	h := t.Hour()
587
588	if h > 12 {
589		h -= 12
590	}
591
592	b = strconv.AppendInt(b, int64(h), 10)
593	b = append(b, pa.timeSeparator...)
594
595	if t.Minute() < 10 {
596		b = append(b, '0')
597	}
598
599	b = strconv.AppendInt(b, int64(t.Minute()), 10)
600	b = append(b, pa.timeSeparator...)
601
602	if t.Second() < 10 {
603		b = append(b, '0')
604	}
605
606	b = strconv.AppendInt(b, int64(t.Second()), 10)
607	b = append(b, []byte{0x20}...)
608
609	if t.Hour() < 12 {
610		b = append(b, pa.periodsAbbreviated[0]...)
611	} else {
612		b = append(b, pa.periodsAbbreviated[1]...)
613	}
614
615	b = append(b, []byte{0x20}...)
616
617	tz, _ := t.Zone()
618	b = append(b, tz...)
619
620	return string(b)
621}
622
623// FmtTimeFull returns the full time representation of 't' for 'pa'
624func (pa *pa) FmtTimeFull(t time.Time) string {
625
626	b := make([]byte, 0, 32)
627
628	h := t.Hour()
629
630	if h > 12 {
631		h -= 12
632	}
633
634	b = strconv.AppendInt(b, int64(h), 10)
635	b = append(b, pa.timeSeparator...)
636
637	if t.Minute() < 10 {
638		b = append(b, '0')
639	}
640
641	b = strconv.AppendInt(b, int64(t.Minute()), 10)
642	b = append(b, pa.timeSeparator...)
643
644	if t.Second() < 10 {
645		b = append(b, '0')
646	}
647
648	b = strconv.AppendInt(b, int64(t.Second()), 10)
649	b = append(b, []byte{0x20}...)
650
651	if t.Hour() < 12 {
652		b = append(b, pa.periodsAbbreviated[0]...)
653	} else {
654		b = append(b, pa.periodsAbbreviated[1]...)
655	}
656
657	b = append(b, []byte{0x20}...)
658
659	tz, _ := t.Zone()
660
661	if btz, ok := pa.timezones[tz]; ok {
662		b = append(b, btz...)
663	} else {
664		b = append(b, tz...)
665	}
666
667	return string(b)
668}
669