OSDN Git Service

new repo
[bytom/vapor.git] / vendor / github.com / go-playground / locales / dz / dz.go
1 package dz
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 dz 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         percentSuffix      string
22         perMille           string
23         timeSeparator      string
24         inifinity          string
25         currencies         []string // idx = enum of currency code
26         monthsAbbreviated  []string
27         monthsNarrow       []string
28         monthsWide         []string
29         daysAbbreviated    []string
30         daysNarrow         []string
31         daysShort          []string
32         daysWide           []string
33         periodsAbbreviated []string
34         periodsNarrow      []string
35         periodsShort       []string
36         periodsWide        []string
37         erasAbbreviated    []string
38         erasNarrow         []string
39         erasWide           []string
40         timezones          map[string]string
41 }
42
43 // New returns a new instance of translator for the 'dz' locale
44 func New() locales.Translator {
45         return &dz{
46                 locale:             "dz",
47                 pluralsCardinal:    []locales.PluralRule{6},
48                 pluralsOrdinal:     nil,
49                 pluralsRange:       nil,
50                 decimal:            ".",
51                 group:              ",",
52                 minus:              "-",
53                 percent:            "%",
54                 perMille:           "‰",
55                 timeSeparator:      ":",
56                 inifinity:          "གྲངས་མེད",
57                 currencies:         []string{"ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AU$", "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", "Nu.", "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", "ILS", "₹", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JP¥", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KR₩", "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", "TH฿", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "NT$", "TZS", "UAH", "UAK", "UGS", "UGX", "US$", "USN", "USS", "UYI", "UYP", "UYU", "UZS", "VEB", "VEF", "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"},
58                 percentSuffix:      " ",
59                 monthsAbbreviated:  []string{"", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩", "༡༠", "༡༡", "12"},
60                 monthsNarrow:       []string{"", "༡", "༢", "༣", "4", "༥", "༦", "༧", "༨", "9", "༡༠", "༡༡", "༡༢"},
61                 monthsWide:         []string{"", "ཟླ་དངཔ་", "ཟླ་གཉིས་པ་", "ཟླ་གསུམ་པ་", "ཟླ་བཞི་པ་", "ཟླ་ལྔ་པ་", "ཟླ་དྲུག་པ", "ཟླ་བདུན་པ་", "ཟླ་བརྒྱད་པ་", "ཟླ་དགུ་པ་", "ཟླ་བཅུ་པ་", "ཟླ་བཅུ་གཅིག་པ་", "ཟླ་བཅུ་གཉིས་པ་"},
62                 daysAbbreviated:    []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"},
63                 daysNarrow:         []string{"ཟླ", "མིར", "ལྷག", "ཕུར", "སངྶ", "སྤེན", "ཉི"},
64                 daysShort:          []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"},
65                 daysWide:           []string{"གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་", "གཟའ་ཉི་མ་"},
66                 periodsAbbreviated: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"},
67                 periodsNarrow:      []string{"སྔ་ཆ་", "ཕྱི་ཆ་"},
68                 periodsWide:        []string{"སྔ་ཆ་", "ཕྱི་ཆ་"},
69                 erasAbbreviated:    []string{"BCE", "CE"},
70                 erasNarrow:         []string{"", ""},
71                 erasWide:           []string{"", ""},
72                 timezones:          map[string]string{"LHDT": "LHDT", "HNT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "EDT": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "ECT": "ཨེ་ཀུ་ཌཽ་ཆུ་ཚོད", "CAT": "དབུས་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "BT": "འབྲུག་ཡུལ་ཆུ་ཚོད", "AWST": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "OEZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "NZST": "ནིའུ་ཛི་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "GFT": "ཕིརེནཅ་གི་ཡ་ན་ཆུ་ཚོད", "CLT": "ཅི་ལི་ཚད་ལྡན་ཆུ་ཚོད", "WIT": "ཤར་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "LHST": "LHST", "CLST": "ཅི་ལི་བྱཱར་དུས་ཆུ་ཚོད", "SGT": "SGT", "UYST": "ཡུ་རུ་གུ་ཝཱའི་བྱཱར་དུས་ཆུ་ཚོད", "TMT": "TMT", "HNOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "WAST": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་བྱཱར་དུས་ཆུ་ཚོད", "CHAST": "CHAST", "HNNOMX": "HNNOMX", "HKT": "HKT", "ACDT": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "CST": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "COST": "ཀོ་ལོམ་བྷི་ཡ་བྱཱར་དུས་ཆུ་ཚོད", "AST": "ཨེཊ་ལེན་ཊིཀ་ཚད་ལྡན་ཆུ་ཚོད", "EAT": "ཤར་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "HNPMX": "HNPMX", "PST": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཚད་ལྡན་ཆུ་ཚོད", "HECU": "ཀིའུ་བྷ་ཉིན་སྲུང་ཆུ་ཚོད", "NZDT": "ནིའུ་ཛི་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "WARST": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "SRT": "སུ་རི་ནཱམ་ཆུ་ཚོད", "HAST": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཚད་ལྡན་ཆུ་ཚོད", "MST": "བྱང་ཨ་མི་རི་ཀ་མའུ་ཊེན་ཚད་ལྡན་ཆུ་ཚོད", "∅∅∅": "ཨེ་ཛོརས་བྱཱར་དུས་ཆུ་ཚོད", "ADT": "ཨེཊ་ལེན་ཊིཀ་ཉིན་སྲུང་ཆུ་ཚོད", "TMST": "TMST", "WITA": "དབུས་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "AEST": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "AEDT": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "SAST": "ལྷོ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "WAT": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཚད་ལྡན་ཆུ་ཚོད", "WIB": "ནུབ་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "PDT": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཉིན་སྲུང་ཆུ་ཚོད", "ACWDT": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "OESZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "MESZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "MYT": "MYT", "HEOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "ACST": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "HNCU": "ཀིའུ་བྷ་ཚད་ལྡན་ཆུ་ཚོད", "MEZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "HADT": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཉིན་སྲུང་ཆུ་ཚོད", "JST": "ཇ་པཱན་ཚད་ལྡན་ཆུ་ཚོད", "ART": "ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "HNEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "EST": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "AKST": "ཨ་ལསི་ཀ་ཚད་ལྡན་ཆུ་ཚོད", "WESZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "HEPMX": "HEPMX", "AWDT": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "VET": "བེ་ནི་ཛུ་ཝེ་ལ་ཆུ་ཚོད", "HAT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "CDT": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "UYT": "ཡུ་རུ་གུ་ཝཱའི་ཚད་ལྡན་ཆུ་ཚོད", "JDT": "ཇ་པཱན་ཉིན་སྲུང་ཆུ་ཚོད", "AKDT": "ཨ་ལསི་ཀ་ཉིན་སྲུང་ཆུ་ཚོད", "HNPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཚད་ལྡན་ཆུ་ཚོད", "CHADT": "CHADT", "ACWST": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "COT": "ཀོ་ལོམ་བྷི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "ARST": "ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "HEEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "HKST": "HKST", "GYT": "གུ་ཡ་ན་ཆུ་ཚོད", "MDT": "བྱང་ཨ་མི་རི་ཀ་མའུ་ཊེན་ཉིན་སྲུང་ཆུ་ཚོད", "HENOMX": "HENOMX", "GMT": "གིརིན་ཝིཆ་ལུ་ཡོད་པའི་ཆུ་ཚོད", "ChST": "ChST", "BOT": "བྷོ་ལི་བི་ཡ་ཆུ་ཚོད", "WART": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "WEZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "HEPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཉིན་སྲུང་ཆུ་ཚོད", "IST": "རྒྱ་གར་ཆུ་ཚོད"},
73         }
74 }
75
76 // Locale returns the current translators string locale
77 func (dz *dz) Locale() string {
78         return dz.locale
79 }
80
81 // PluralsCardinal returns the list of cardinal plural rules associated with 'dz'
82 func (dz *dz) PluralsCardinal() []locales.PluralRule {
83         return dz.pluralsCardinal
84 }
85
86 // PluralsOrdinal returns the list of ordinal plural rules associated with 'dz'
87 func (dz *dz) PluralsOrdinal() []locales.PluralRule {
88         return dz.pluralsOrdinal
89 }
90
91 // PluralsRange returns the list of range plural rules associated with 'dz'
92 func (dz *dz) PluralsRange() []locales.PluralRule {
93         return dz.pluralsRange
94 }
95
96 // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dz'
97 func (dz *dz) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
98         return locales.PluralRuleOther
99 }
100
101 // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dz'
102 func (dz *dz) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
103         return locales.PluralRuleUnknown
104 }
105
106 // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dz'
107 func (dz *dz) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
108         return locales.PluralRuleUnknown
109 }
110
111 // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
112 func (dz *dz) MonthAbbreviated(month time.Month) string {
113         return dz.monthsAbbreviated[month]
114 }
115
116 // MonthsAbbreviated returns the locales abbreviated months
117 func (dz *dz) MonthsAbbreviated() []string {
118         return dz.monthsAbbreviated[1:]
119 }
120
121 // MonthNarrow returns the locales narrow month given the 'month' provided
122 func (dz *dz) MonthNarrow(month time.Month) string {
123         return dz.monthsNarrow[month]
124 }
125
126 // MonthsNarrow returns the locales narrow months
127 func (dz *dz) MonthsNarrow() []string {
128         return dz.monthsNarrow[1:]
129 }
130
131 // MonthWide returns the locales wide month given the 'month' provided
132 func (dz *dz) MonthWide(month time.Month) string {
133         return dz.monthsWide[month]
134 }
135
136 // MonthsWide returns the locales wide months
137 func (dz *dz) MonthsWide() []string {
138         return dz.monthsWide[1:]
139 }
140
141 // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
142 func (dz *dz) WeekdayAbbreviated(weekday time.Weekday) string {
143         return dz.daysAbbreviated[weekday]
144 }
145
146 // WeekdaysAbbreviated returns the locales abbreviated weekdays
147 func (dz *dz) WeekdaysAbbreviated() []string {
148         return dz.daysAbbreviated
149 }
150
151 // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
152 func (dz *dz) WeekdayNarrow(weekday time.Weekday) string {
153         return dz.daysNarrow[weekday]
154 }
155
156 // WeekdaysNarrow returns the locales narrow weekdays
157 func (dz *dz) WeekdaysNarrow() []string {
158         return dz.daysNarrow
159 }
160
161 // WeekdayShort returns the locales short weekday given the 'weekday' provided
162 func (dz *dz) WeekdayShort(weekday time.Weekday) string {
163         return dz.daysShort[weekday]
164 }
165
166 // WeekdaysShort returns the locales short weekdays
167 func (dz *dz) WeekdaysShort() []string {
168         return dz.daysShort
169 }
170
171 // WeekdayWide returns the locales wide weekday given the 'weekday' provided
172 func (dz *dz) WeekdayWide(weekday time.Weekday) string {
173         return dz.daysWide[weekday]
174 }
175
176 // WeekdaysWide returns the locales wide weekdays
177 func (dz *dz) WeekdaysWide() []string {
178         return dz.daysWide
179 }
180
181 // Decimal returns the decimal point of number
182 func (dz *dz) Decimal() string {
183         return dz.decimal
184 }
185
186 // Group returns the group of number
187 func (dz *dz) Group() string {
188         return dz.group
189 }
190
191 // Group returns the minus sign of number
192 func (dz *dz) Minus() string {
193         return dz.minus
194 }
195
196 // FmtNumber returns 'num' with digits/precision of 'v' for 'dz' and handles both Whole and Real numbers based on 'v'
197 func (dz *dz) FmtNumber(num float64, v uint64) string {
198
199         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
200         l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
201         count := 0
202         inWhole := v == 0
203         inSecondary := false
204         groupThreshold := 3
205
206         b := make([]byte, 0, l)
207
208         for i := len(s) - 1; i >= 0; i-- {
209
210                 if s[i] == '.' {
211                         b = append(b, dz.decimal[0])
212                         inWhole = true
213                         continue
214                 }
215
216                 if inWhole {
217
218                         if count == groupThreshold {
219                                 b = append(b, dz.group[0])
220                                 count = 1
221
222                                 if !inSecondary {
223                                         inSecondary = true
224                                         groupThreshold = 2
225                                 }
226                         } else {
227                                 count++
228                         }
229                 }
230
231                 b = append(b, s[i])
232         }
233
234         if num < 0 {
235                 b = append(b, dz.minus[0])
236         }
237
238         // reverse
239         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
240                 b[i], b[j] = b[j], b[i]
241         }
242
243         return string(b)
244 }
245
246 // FmtPercent returns 'num' with digits/precision of 'v' for 'dz' and handles both Whole and Real numbers based on 'v'
247 // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
248 func (dz *dz) FmtPercent(num float64, v uint64) string {
249         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
250         l := len(s) + 5
251         b := make([]byte, 0, l)
252
253         for i := len(s) - 1; i >= 0; i-- {
254
255                 if s[i] == '.' {
256                         b = append(b, dz.decimal[0])
257                         continue
258                 }
259
260                 b = append(b, s[i])
261         }
262
263         if num < 0 {
264                 b = append(b, dz.minus[0])
265         }
266
267         // reverse
268         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
269                 b[i], b[j] = b[j], b[i]
270         }
271
272         b = append(b, dz.percentSuffix...)
273
274         b = append(b, dz.percent...)
275
276         return string(b)
277 }
278
279 // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dz'
280 func (dz *dz) FmtCurrency(num float64, v uint64, currency currency.Type) string {
281
282         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
283         symbol := dz.currencies[currency]
284         l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
285         count := 0
286         inWhole := v == 0
287         inSecondary := false
288         groupThreshold := 3
289
290         b := make([]byte, 0, l)
291
292         for i := len(s) - 1; i >= 0; i-- {
293
294                 if s[i] == '.' {
295                         b = append(b, dz.decimal[0])
296                         inWhole = true
297                         continue
298                 }
299
300                 if inWhole {
301
302                         if count == groupThreshold {
303                                 b = append(b, dz.group[0])
304                                 count = 1
305
306                                 if !inSecondary {
307                                         inSecondary = true
308                                         groupThreshold = 2
309                                 }
310                         } else {
311                                 count++
312                         }
313                 }
314
315                 b = append(b, s[i])
316         }
317
318         for j := len(symbol) - 1; j >= 0; j-- {
319                 b = append(b, symbol[j])
320         }
321
322         if num < 0 {
323                 b = append(b, dz.minus[0])
324         }
325
326         // reverse
327         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
328                 b[i], b[j] = b[j], b[i]
329         }
330
331         if int(v) < 2 {
332
333                 if v == 0 {
334                         b = append(b, dz.decimal...)
335                 }
336
337                 for i := 0; i < 2-int(v); i++ {
338                         b = append(b, '0')
339                 }
340         }
341
342         return string(b)
343 }
344
345 // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dz'
346 // in accounting notation.
347 func (dz *dz) FmtAccounting(num float64, v uint64, currency currency.Type) string {
348
349         s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
350         symbol := dz.currencies[currency]
351         l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
352         count := 0
353         inWhole := v == 0
354         inSecondary := false
355         groupThreshold := 3
356
357         b := make([]byte, 0, l)
358
359         for i := len(s) - 1; i >= 0; i-- {
360
361                 if s[i] == '.' {
362                         b = append(b, dz.decimal[0])
363                         inWhole = true
364                         continue
365                 }
366
367                 if inWhole {
368
369                         if count == groupThreshold {
370                                 b = append(b, dz.group[0])
371                                 count = 1
372
373                                 if !inSecondary {
374                                         inSecondary = true
375                                         groupThreshold = 2
376                                 }
377                         } else {
378                                 count++
379                         }
380                 }
381
382                 b = append(b, s[i])
383         }
384
385         if num < 0 {
386
387                 for j := len(symbol) - 1; j >= 0; j-- {
388                         b = append(b, symbol[j])
389                 }
390
391                 b = append(b, dz.minus[0])
392
393         } else {
394
395                 for j := len(symbol) - 1; j >= 0; j-- {
396                         b = append(b, symbol[j])
397                 }
398
399         }
400
401         // reverse
402         for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
403                 b[i], b[j] = b[j], b[i]
404         }
405
406         if int(v) < 2 {
407
408                 if v == 0 {
409                         b = append(b, dz.decimal...)
410                 }
411
412                 for i := 0; i < 2-int(v); i++ {
413                         b = append(b, '0')
414                 }
415         }
416
417         return string(b)
418 }
419
420 // FmtDateShort returns the short date representation of 't' for 'dz'
421 func (dz *dz) FmtDateShort(t time.Time) string {
422
423         b := make([]byte, 0, 32)
424
425         if t.Year() > 0 {
426                 b = strconv.AppendInt(b, int64(t.Year()), 10)
427         } else {
428                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
429         }
430
431         b = append(b, []byte{0x2d}...)
432
433         if t.Month() < 10 {
434                 b = append(b, '0')
435         }
436
437         b = strconv.AppendInt(b, int64(t.Month()), 10)
438
439         b = append(b, []byte{0x2d}...)
440
441         if t.Day() < 10 {
442                 b = append(b, '0')
443         }
444
445         b = strconv.AppendInt(b, int64(t.Day()), 10)
446
447         return string(b)
448 }
449
450 // FmtDateMedium returns the medium date representation of 't' for 'dz'
451 func (dz *dz) FmtDateMedium(t time.Time) string {
452
453         b := make([]byte, 0, 32)
454
455         b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...)
456
457         if t.Year() > 0 {
458                 b = strconv.AppendInt(b, int64(t.Year()), 10)
459         } else {
460                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
461         }
462
463         b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9f, 0xe0, 0xbe, 0xb3, 0xe0, 0xbc, 0x8b}...)
464         b = append(b, dz.monthsAbbreviated[t.Month()]...)
465         b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
466
467         if t.Day() < 10 {
468                 b = append(b, '0')
469         }
470
471         b = strconv.AppendInt(b, int64(t.Day()), 10)
472
473         return string(b)
474 }
475
476 // FmtDateLong returns the long date representation of 't' for 'dz'
477 func (dz *dz) FmtDateLong(t time.Time) string {
478
479         b := make([]byte, 0, 32)
480
481         b = append(b, []byte{0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...)
482
483         if t.Year() > 0 {
484                 b = strconv.AppendInt(b, int64(t.Year()), 10)
485         } else {
486                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
487         }
488
489         b = append(b, []byte{0x20}...)
490         b = append(b, dz.monthsWide[t.Month()]...)
491         b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b, 0x20}...)
492
493         if t.Day() < 10 {
494                 b = append(b, '0')
495         }
496
497         b = strconv.AppendInt(b, int64(t.Day()), 10)
498
499         return string(b)
500 }
501
502 // FmtDateFull returns the full date representation of 't' for 'dz'
503 func (dz *dz) FmtDateFull(t time.Time) string {
504
505         b := make([]byte, 0, 32)
506
507         b = append(b, dz.daysWide[t.Weekday()]...)
508         b = append(b, []byte{0x2c, 0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0xa4, 0xe0, 0xbe, 0xb1, 0xe0, 0xbd, 0xb2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0xa3, 0xe0, 0xbd, 0xbc, 0xe0, 0xbc, 0x8b}...)
509
510         if t.Year() > 0 {
511                 b = strconv.AppendInt(b, int64(t.Year()), 10)
512         } else {
513                 b = strconv.AppendInt(b, int64(-t.Year()), 10)
514         }
515
516         b = append(b, []byte{0x20}...)
517         b = append(b, dz.monthsWide[t.Month()]...)
518         b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
519
520         if t.Day() < 10 {
521                 b = append(b, '0')
522         }
523
524         b = strconv.AppendInt(b, int64(t.Day()), 10)
525
526         return string(b)
527 }
528
529 // FmtTimeShort returns the short time representation of 't' for 'dz'
530 func (dz *dz) FmtTimeShort(t time.Time) string {
531
532         b := make([]byte, 0, 32)
533
534         b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...)
535
536         h := t.Hour()
537
538         if h > 12 {
539                 h -= 12
540         }
541
542         b = strconv.AppendInt(b, int64(h), 10)
543         b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)
544
545         if t.Minute() < 10 {
546                 b = append(b, '0')
547         }
548
549         b = strconv.AppendInt(b, int64(t.Minute()), 10)
550         b = append(b, []byte{0x20}...)
551
552         if t.Hour() < 12 {
553                 b = append(b, dz.periodsAbbreviated[0]...)
554         } else {
555                 b = append(b, dz.periodsAbbreviated[1]...)
556         }
557
558         return string(b)
559 }
560
561 // FmtTimeMedium returns the medium time representation of 't' for 'dz'
562 func (dz *dz) FmtTimeMedium(t time.Time) string {
563
564         b := make([]byte, 0, 32)
565
566         b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b}...)
567
568         h := t.Hour()
569
570         if h > 12 {
571                 h -= 12
572         }
573
574         b = strconv.AppendInt(b, int64(h), 10)
575         b = append(b, dz.timeSeparator...)
576
577         if t.Minute() < 10 {
578                 b = append(b, '0')
579         }
580
581         b = strconv.AppendInt(b, int64(t.Minute()), 10)
582         b = append(b, dz.timeSeparator...)
583
584         if t.Second() < 10 {
585                 b = append(b, '0')
586         }
587
588         b = strconv.AppendInt(b, int64(t.Second()), 10)
589         b = append(b, []byte{0x20}...)
590
591         if t.Hour() < 12 {
592                 b = append(b, dz.periodsAbbreviated[0]...)
593         } else {
594                 b = append(b, dz.periodsAbbreviated[1]...)
595         }
596
597         return string(b)
598 }
599
600 // FmtTimeLong returns the long time representation of 't' for 'dz'
601 func (dz *dz) FmtTimeLong(t time.Time) string {
602
603         b := make([]byte, 0, 32)
604
605         b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...)
606
607         h := t.Hour()
608
609         if h > 12 {
610                 h -= 12
611         }
612
613         b = strconv.AppendInt(b, int64(h), 10)
614         b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)
615
616         if t.Minute() < 10 {
617                 b = append(b, '0')
618         }
619
620         b = strconv.AppendInt(b, int64(t.Minute()), 10)
621         b = append(b, dz.timeSeparator...)
622
623         if t.Second() < 10 {
624                 b = append(b, '0')
625         }
626
627         b = strconv.AppendInt(b, int64(t.Second()), 10)
628         b = append(b, []byte{0x20}...)
629
630         if t.Hour() < 12 {
631                 b = append(b, dz.periodsAbbreviated[0]...)
632         } else {
633                 b = append(b, dz.periodsAbbreviated[1]...)
634         }
635
636         b = append(b, []byte{0x20}...)
637
638         tz, _ := t.Zone()
639         b = append(b, tz...)
640
641         return string(b)
642 }
643
644 // FmtTimeFull returns the full time representation of 't' for 'dz'
645 func (dz *dz) FmtTimeFull(t time.Time) string {
646
647         b := make([]byte, 0, 32)
648
649         b = append(b, []byte{0xe0, 0xbd, 0x86, 0xe0, 0xbd, 0xb4, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xbc, 0xe0, 0xbd, 0x91, 0xe0, 0xbc, 0x8b, 0x20}...)
650
651         h := t.Hour()
652
653         if h > 12 {
654                 h -= 12
655         }
656
657         b = strconv.AppendInt(b, int64(h), 10)
658         b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)
659
660         if t.Minute() < 10 {
661                 b = append(b, '0')
662         }
663
664         b = strconv.AppendInt(b, int64(t.Minute()), 10)
665         b = append(b, dz.timeSeparator...)
666
667         if t.Second() < 10 {
668                 b = append(b, '0')
669         }
670
671         b = strconv.AppendInt(b, int64(t.Second()), 10)
672         b = append(b, []byte{0x20}...)
673
674         if t.Hour() < 12 {
675                 b = append(b, dz.periodsAbbreviated[0]...)
676         } else {
677                 b = append(b, dz.periodsAbbreviated[1]...)
678         }
679
680         b = append(b, []byte{0x20}...)
681
682         tz, _ := t.Zone()
683
684         if btz, ok := dz.timezones[tz]; ok {
685                 b = append(b, btz...)
686         } else {
687                 b = append(b, tz...)
688         }
689
690         return string(b)
691 }