8 "github.com/go-playground/locales"
9 "github.com/go-playground/locales/currency"
14 pluralsCardinal []locales.PluralRule
15 pluralsOrdinal []locales.PluralRule
16 pluralsRange []locales.PluralRule
24 currencies []string // idx = enum of currency code
25 monthsAbbreviated []string
28 daysAbbreviated []string
32 periodsAbbreviated []string
33 periodsNarrow []string
36 erasAbbreviated []string
39 timezones map[string]string
42 // New returns a new instance of translator for the 'kn' locale
43 func New() locales.Translator {
46 pluralsCardinal: []locales.PluralRule{2, 6},
47 pluralsOrdinal: []locales.PluralRule{6},
48 pluralsRange: []locales.PluralRule{2, 6},
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", "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", "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", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "SUR", "SVC", "SYP", "SZL", "฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "₫", "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{"HNPM": "ಸೇಂಟ್ ಪಿಯರ್ ಮತ್ತು ಮಿಕ್ವೆಲನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "MST": "ಮಕಾವ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "AWST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪಶ್ಚಿಮ ಪ್ರಮಾಣಿತ ಸಮಯ", "AEDT": "ಪೂರ್ವ ಆಸ್ಟ್ರೇಲಿಯಾದ ಹಗಲು ಸಮಯ", "ACDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಹಗಲು ಸಮಯ", "COT": "ಕೊಲಂಬಿಯಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "GYT": "ಗಯಾನಾ ಸಮಯ", "PDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೆಸಿಫಿಕ್ ದಿನದ ಸಮಯ", "MEZ": "ಮಧ್ಯ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "EAT": "ಪೂರ್ವ ಆಫ್ರಿಕಾ ಸಮಯ", "HNEG": "ಪೂರ್ವ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ChST": "ಚಮೋರೋ ಪ್ರಮಾಣಿತ ಸಮಯ", "CHADT": "ಚಥಾಮ್ ಹಗಲು ಸಮಯ", "HEOG": "ಪಶ್ಚಿಮ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಬೇಸಿಗೆ ಸಮಯ", "CAT": "ಮಧ್ಯ ಆಫ್ರಿಕಾ ಸಮಯ", "WIB": "ಪಶ್ಚಿಮ ಇಂಡೋನೇಷಿಯ ಸಮಯ", "UYT": "ಉರುಗ್ವೇ ಪ್ರಮಾಣಿತ ಸಮಯ", "LHDT": "ಲಾರ್ಡ್ ಹೋವ್ ಬೆಳಗಿನ ಸಮಯ", "HEEG": "ಪೂರ್ವ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಬೇಸಿಗೆ ಸಮಯ", "HEPMX": "ಮೆಕ್ಸಿಕನ್ ಪೆಸಿಫಿಕ್ ಹಗಲು ಸಮಯ", "WIT": "ಪೂರ್ವ ಇಂಡೋನೇಷಿಯಾ ಸಮಯ", "MESZ": "ಮಧ್ಯ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "HAST": "ಹವಾಯಿ-ಅಲ್ಯುಟಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "JST": "ಜಪಾನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "∅∅∅": "ಅಮೆಜಾನ್ ಬೇಸಿಗೆ ಸಮಯ", "CDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಕೇಂದ್ರೀಯ ದಿನದ ಸಮಯ", "WART": "ಪಶ್ಚಿಮ ಅರ್ಜೆಂಟೀನಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "VET": "ವೆನಿಜುವೆಲಾ ಸಮಯ", "HNNOMX": "ವಾಯವ್ಯ ಮೆಕ್ಸಿಕೊ ಪ್ರಮಾಣಿತ ಸಮಯ", "SAST": "ದಕ್ಷಿಣ ಆಫ್ರಿಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "NZDT": "ನ್ಯೂಜಿಲ್ಯಾಂಡ್ ಹಗಲು ಸಮಯ", "HKST": "ಹಾಂಗ್ ಕಾಂಗ್ ಬೇಸಿಗೆ ಸಮಯ", "AWDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪಶ್ಚಿಮ ಹಗಲು ಸಮಯ", "WAST": "ಪಶ್ಚಿಮ ಆಫ್ರಿಕಾ ಬೇಸಿಗೆ ಸಮಯ", "HKT": "ಹಾಂಗ್ ಕಾಂಗ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "MDT": "ಮಕಾವ್ ಬೇಸಿಗೆ ಸಮಯ", "ACWST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪಶ್ಚಿಮ ಪ್ರಮಾಣಿತ ಸಮಯ", "HADT": "ಹವಾಯಿ-ಅಲ್ಯುಟಿಯನ್ ಹಗಲು ಸಮಯ", "HNT": "ನ್ಯೂಫೌಂಡ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "CLST": "ಚಿಲಿ ಬೇಸಿಗೆ ಸಮಯ", "WAT": "ಪಶ್ಚಿಮ ಆಫ್ರಿಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "EST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೂರ್ವದ ಪ್ರಮಾಣಿತ ಸಮಯ", "AKST": "ಅಲಸ್ಕಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HECU": "ಕ್ಯೂಬಾ ದಿನದ ಸಮಯ", "ACWDT": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪಶ್ಚಿಮ ಹಗಲು ಸಮಯ", "WARST": "ಪಶ್ಚಿಮ ಅರ್ಜೆಂಟೀನಾ ಬೇಸಿಗೆ ಸಮಯ", "ART": "ಅರ್ಜೆಂಟೀನಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNOG": "ಪಶ್ಚಿಮ ಗ್ರೀನ್\u200cಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HENOMX": "ವಾಯವ್ಯ ಮೆಕ್ಸಿಕೊ ಹಗಲು ಸಮಯ", "EDT": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೂರ್ವದ ದಿನದ ಸಮಯ", "ACST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಕೇಂದ್ರ ಪ್ರಮಾಣಿತ ಸಮಯ", "BT": "ಭೂತಾನ್ ಸಮಯ", "BOT": "ಬೊಲಿವಿಯಾ ಸಮಯ", "CST": "ಉತ್ತರ ಅಮೆರಿಕದ ಕೇಂದ್ರ ಪ್ರಮಾಣಿತ ಸಮಯ", "WITA": "ಮಧ್ಯ ಇಂಡೋನೇಷಿಯಾ ಸಮಯ", "AEST": "ಆಸ್ಟ್ರೇಲಿಯಾದ ಪೂರ್ವ ಪ್ರಮಾಣಿತ ಸಮಯ", "COST": "ಕೊಲಂಬಿಯಾ ಬೇಸಿಗೆ ಸಮಯ", "SRT": "ಸುರಿನೇಮ್ ಸಮಯ", "WEZ": "ಪಶ್ಚಿಮ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "GMT": "ಗ್ರೀನ್\u200cವಿಚ್ ಸರಾಸರಿ ಕಾಲಮಾನ", "MYT": "ಮಲೇಷಿಯಾ ಸಮಯ", "IST": "ಭಾರತೀಯ ಪ್ರಮಾಣಿತ ಸಮಯ", "WESZ": "ಪಶ್ಚಿಮ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "HEPM": "ಸೇಂಟ್ ಪಿಯರ್ ಮತ್ತು ಮಿಕ್ವೆಲನ್ ಹಗಲು ಸಮಯ", "AKDT": "\u200cಅಲಾಸ್ಕಾ ಹಗಲು ಸಮಯ", "HNPMX": "ಮೆಕ್ಸಿಕನ್ ಪೆಸಿಫಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ADT": "ಅಟ್ಲಾಂಟಿಕ್ ದಿನದ ಸಮಯ", "GFT": "ಫ್ರೆಂಚ್ ಗಯಾನಾ ಸಮಯ", "ECT": "ಈಕ್ವೆಡಾರ್ ಸಮಯ", "TMT": "ತುರ್ಕ್\u200cಮೇನಿಸ್ತಾನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "TMST": "ತುರ್ಕ್\u200cಮೇನಿಸ್ತಾನ್ ಬೇಸಿಗೆ ಸಮಯ", "OEZ": "ಪೂರ್ವ ಯುರೋಪಿಯನ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "HAT": "ನ್ಯೂಫೌಂಡ್\u200cಲ್ಯಾಂಡ್ ದಿನದ ಸಮಯ", "CLT": "ಚಿಲಿ ಪ್ರಮಾಣಿತ ಸಮಯ", "HNCU": "ಕ್ಯೂಬಾ ಪ್ರಮಾಣಿತ ಸಮಯ", "JDT": "ಜಪಾನ್ ಹಗಲು ಸಮಯ", "OESZ": "ಪೂರ್ವ ಯುರೋಪಿಯನ್ ಬೇಸಿಗೆ ಸಮಯ", "LHST": "ಲಾರ್ಡ್ ಹೋವ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "AST": "ಅಟ್ಲಾಂಟಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "ARST": "ಅರ್ಜೆಂಟಿನಾ ಬೇಸಿಗೆ ಸಮಯ", "CHAST": "ಚಥಾಮ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "UYST": "ಉರುಗ್ವೇ ಬೇಸಿಗೆ ಸಮಯ", "NZST": "ನ್ಯೂಜಿಲ್ಯಾಂಡ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "SGT": "ಸಿಂಗಾಪುರ್ ಪ್ರಮಾಣಿತ ಸಮಯ", "PST": "ಉತ್ತರ ಅಮೆರಿಕದ ಪೆಸಿಫಿಕ್ ಪ್ರಮಾಣಿತ ಸಮಯ"},
74 // Locale returns the current translators string locale
75 func (kn *kn) Locale() string {
79 // PluralsCardinal returns the list of cardinal plural rules associated with 'kn'
80 func (kn *kn) PluralsCardinal() []locales.PluralRule {
81 return kn.pluralsCardinal
84 // PluralsOrdinal returns the list of ordinal plural rules associated with 'kn'
85 func (kn *kn) PluralsOrdinal() []locales.PluralRule {
86 return kn.pluralsOrdinal
89 // PluralsRange returns the list of range plural rules associated with 'kn'
90 func (kn *kn) PluralsRange() []locales.PluralRule {
91 return kn.pluralsRange
94 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'kn'
95 func (kn *kn) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
100 if (i == 0) || (n == 1) {
101 return locales.PluralRuleOne
104 return locales.PluralRuleOther
107 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'kn'
108 func (kn *kn) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
109 return locales.PluralRuleOther
112 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'kn'
113 func (kn *kn) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
115 start := kn.CardinalPluralRule(num1, v1)
116 end := kn.CardinalPluralRule(num2, v2)
118 if start == locales.PluralRuleOne && end == locales.PluralRuleOne {
119 return locales.PluralRuleOne
120 } else if start == locales.PluralRuleOne && end == locales.PluralRuleOther {
121 return locales.PluralRuleOther
124 return locales.PluralRuleOther
128 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
129 func (kn *kn) MonthAbbreviated(month time.Month) string {
130 return kn.monthsAbbreviated[month]
133 // MonthsAbbreviated returns the locales abbreviated months
134 func (kn *kn) MonthsAbbreviated() []string {
135 return kn.monthsAbbreviated[1:]
138 // MonthNarrow returns the locales narrow month given the 'month' provided
139 func (kn *kn) MonthNarrow(month time.Month) string {
140 return kn.monthsNarrow[month]
143 // MonthsNarrow returns the locales narrow months
144 func (kn *kn) MonthsNarrow() []string {
145 return kn.monthsNarrow[1:]
148 // MonthWide returns the locales wide month given the 'month' provided
149 func (kn *kn) MonthWide(month time.Month) string {
150 return kn.monthsWide[month]
153 // MonthsWide returns the locales wide months
154 func (kn *kn) MonthsWide() []string {
155 return kn.monthsWide[1:]
158 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
159 func (kn *kn) WeekdayAbbreviated(weekday time.Weekday) string {
160 return kn.daysAbbreviated[weekday]
163 // WeekdaysAbbreviated returns the locales abbreviated weekdays
164 func (kn *kn) WeekdaysAbbreviated() []string {
165 return kn.daysAbbreviated
168 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
169 func (kn *kn) WeekdayNarrow(weekday time.Weekday) string {
170 return kn.daysNarrow[weekday]
173 // WeekdaysNarrow returns the locales narrow weekdays
174 func (kn *kn) WeekdaysNarrow() []string {
178 // WeekdayShort returns the locales short weekday given the 'weekday' provided
179 func (kn *kn) WeekdayShort(weekday time.Weekday) string {
180 return kn.daysShort[weekday]
183 // WeekdaysShort returns the locales short weekdays
184 func (kn *kn) WeekdaysShort() []string {
188 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
189 func (kn *kn) WeekdayWide(weekday time.Weekday) string {
190 return kn.daysWide[weekday]
193 // WeekdaysWide returns the locales wide weekdays
194 func (kn *kn) WeekdaysWide() []string {
198 // Decimal returns the decimal point of number
199 func (kn *kn) Decimal() string {
203 // Group returns the group of number
204 func (kn *kn) Group() string {
208 // Group returns the minus sign of number
209 func (kn *kn) Minus() string {
213 // FmtNumber returns 'num' with digits/precision of 'v' for 'kn' and handles both Whole and Real numbers based on 'v'
214 func (kn *kn) FmtNumber(num float64, v uint64) string {
216 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
217 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
220 b := make([]byte, 0, l)
222 for i := len(s) - 1; i >= 0; i-- {
225 b = append(b, kn.decimal[0])
232 b = append(b, kn.group[0])
243 b = append(b, kn.minus[0])
247 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
248 b[i], b[j] = b[j], b[i]
254 // FmtPercent returns 'num' with digits/precision of 'v' for 'kn' and handles both Whole and Real numbers based on 'v'
255 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
256 func (kn *kn) FmtPercent(num float64, v uint64) string {
257 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
259 b := make([]byte, 0, l)
261 for i := len(s) - 1; i >= 0; i-- {
264 b = append(b, kn.decimal[0])
272 b = append(b, kn.minus[0])
276 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
277 b[i], b[j] = b[j], b[i]
280 b = append(b, kn.percent...)
285 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'kn'
286 func (kn *kn) FmtCurrency(num float64, v uint64, currency currency.Type) string {
288 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
289 symbol := kn.currencies[currency]
290 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
293 b := make([]byte, 0, l)
295 for i := len(s) - 1; i >= 0; i-- {
298 b = append(b, kn.decimal[0])
305 b = append(b, kn.group[0])
315 for j := len(symbol) - 1; j >= 0; j-- {
316 b = append(b, symbol[j])
320 b = append(b, kn.minus[0])
324 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
325 b[i], b[j] = b[j], b[i]
331 b = append(b, kn.decimal...)
334 for i := 0; i < 2-int(v); i++ {
342 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'kn'
343 // in accounting notation.
344 func (kn *kn) FmtAccounting(num float64, v uint64, currency currency.Type) string {
346 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
347 symbol := kn.currencies[currency]
348 l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
351 b := make([]byte, 0, l)
353 for i := len(s) - 1; i >= 0; i-- {
356 b = append(b, kn.decimal[0])
363 b = append(b, kn.group[0])
375 for j := len(symbol) - 1; j >= 0; j-- {
376 b = append(b, symbol[j])
379 b = append(b, kn.minus[0])
383 for j := len(symbol) - 1; j >= 0; j-- {
384 b = append(b, symbol[j])
390 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
391 b[i], b[j] = b[j], b[i]
397 b = append(b, kn.decimal...)
400 for i := 0; i < 2-int(v); i++ {
408 // FmtDateShort returns the short date representation of 't' for 'kn'
409 func (kn *kn) FmtDateShort(t time.Time) string {
411 b := make([]byte, 0, 32)
413 b = strconv.AppendInt(b, int64(t.Day()), 10)
414 b = append(b, []byte{0x2f}...)
415 b = strconv.AppendInt(b, int64(t.Month()), 10)
416 b = append(b, []byte{0x2f}...)
419 b = append(b, strconv.Itoa(t.Year())[2:]...)
421 b = append(b, strconv.Itoa(t.Year())[1:]...)
427 // FmtDateMedium returns the medium date representation of 't' for 'kn'
428 func (kn *kn) FmtDateMedium(t time.Time) string {
430 b := make([]byte, 0, 32)
432 b = append(b, kn.monthsAbbreviated[t.Month()]...)
433 b = append(b, []byte{0x20}...)
434 b = strconv.AppendInt(b, int64(t.Day()), 10)
435 b = append(b, []byte{0x2c, 0x20}...)
438 b = strconv.AppendInt(b, int64(t.Year()), 10)
440 b = strconv.AppendInt(b, int64(-t.Year()), 10)
446 // FmtDateLong returns the long date representation of 't' for 'kn'
447 func (kn *kn) FmtDateLong(t time.Time) string {
449 b := make([]byte, 0, 32)
451 b = append(b, kn.monthsWide[t.Month()]...)
452 b = append(b, []byte{0x20}...)
453 b = strconv.AppendInt(b, int64(t.Day()), 10)
454 b = append(b, []byte{0x2c, 0x20}...)
457 b = strconv.AppendInt(b, int64(t.Year()), 10)
459 b = strconv.AppendInt(b, int64(-t.Year()), 10)
465 // FmtDateFull returns the full date representation of 't' for 'kn'
466 func (kn *kn) FmtDateFull(t time.Time) string {
468 b := make([]byte, 0, 32)
470 b = append(b, kn.daysWide[t.Weekday()]...)
471 b = append(b, []byte{0x2c, 0x20}...)
472 b = append(b, kn.monthsWide[t.Month()]...)
473 b = append(b, []byte{0x20}...)
474 b = strconv.AppendInt(b, int64(t.Day()), 10)
475 b = append(b, []byte{0x2c, 0x20}...)
478 b = strconv.AppendInt(b, int64(t.Year()), 10)
480 b = strconv.AppendInt(b, int64(-t.Year()), 10)
486 // FmtTimeShort returns the short time representation of 't' for 'kn'
487 func (kn *kn) FmtTimeShort(t time.Time) string {
489 b := make([]byte, 0, 32)
501 b = strconv.AppendInt(b, int64(h), 10)
502 b = append(b, kn.timeSeparator...)
508 b = strconv.AppendInt(b, int64(t.Minute()), 10)
509 b = append(b, []byte{0x20}...)
512 b = append(b, kn.periodsAbbreviated[0]...)
514 b = append(b, kn.periodsAbbreviated[1]...)
520 // FmtTimeMedium returns the medium time representation of 't' for 'kn'
521 func (kn *kn) FmtTimeMedium(t time.Time) string {
523 b := make([]byte, 0, 32)
535 b = strconv.AppendInt(b, int64(h), 10)
536 b = append(b, kn.timeSeparator...)
542 b = strconv.AppendInt(b, int64(t.Minute()), 10)
543 b = append(b, kn.timeSeparator...)
549 b = strconv.AppendInt(b, int64(t.Second()), 10)
550 b = append(b, []byte{0x20}...)
553 b = append(b, kn.periodsAbbreviated[0]...)
555 b = append(b, kn.periodsAbbreviated[1]...)
561 // FmtTimeLong returns the long time representation of 't' for 'kn'
562 func (kn *kn) FmtTimeLong(t time.Time) string {
564 b := make([]byte, 0, 32)
576 b = strconv.AppendInt(b, int64(h), 10)
577 b = append(b, kn.timeSeparator...)
583 b = strconv.AppendInt(b, int64(t.Minute()), 10)
584 b = append(b, kn.timeSeparator...)
590 b = strconv.AppendInt(b, int64(t.Second()), 10)
591 b = append(b, []byte{0x20}...)
594 b = append(b, kn.periodsAbbreviated[0]...)
596 b = append(b, kn.periodsAbbreviated[1]...)
599 b = append(b, []byte{0x20}...)
607 // FmtTimeFull returns the full time representation of 't' for 'kn'
608 func (kn *kn) FmtTimeFull(t time.Time) string {
610 b := make([]byte, 0, 32)
622 b = strconv.AppendInt(b, int64(h), 10)
623 b = append(b, kn.timeSeparator...)
629 b = strconv.AppendInt(b, int64(t.Minute()), 10)
630 b = append(b, kn.timeSeparator...)
636 b = strconv.AppendInt(b, int64(t.Second()), 10)
637 b = append(b, []byte{0x20}...)
640 b = append(b, kn.periodsAbbreviated[0]...)
642 b = append(b, kn.periodsAbbreviated[1]...)
645 b = append(b, []byte{0x20}...)
649 if btz, ok := kn.timezones[tz]; ok {
650 b = append(b, btz...)