1package ne 2 3import ( 4 "math" 5 "strconv" 6 "time" 7 8 "github.com/gohugoio/locales" 9 "github.com/gohugoio/locales/currency" 10) 11 12type ne struct { 13 locale string 14 pluralsCardinal []locales.PluralRule 15 pluralsOrdinal []locales.PluralRule 16 pluralsRange []locales.PluralRule 17 decimal string 18 group string 19 minus string 20 percent string 21 perMille string 22 timeSeparator string 23 inifinity string 24 currencies []string // idx = enum of currency code 25 currencyPositivePrefix string 26 currencyNegativePrefix string 27 monthsAbbreviated []string 28 monthsNarrow []string 29 monthsWide []string 30 daysAbbreviated []string 31 daysNarrow []string 32 daysShort []string 33 daysWide []string 34 periodsAbbreviated []string 35 periodsNarrow []string 36 periodsShort []string 37 periodsWide []string 38 erasAbbreviated []string 39 erasNarrow []string 40 erasWide []string 41 timezones map[string]string 42} 43 44// New returns a new instance of translator for the 'ne' locale 45func New() locales.Translator { 46 return &ne{ 47 locale: "ne", 48 pluralsCardinal: []locales.PluralRule{2, 6}, 49 pluralsOrdinal: []locales.PluralRule{2, 6}, 50 pluralsRange: []locales.PluralRule{2, 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", "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", "नेरू", "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", "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"}, 59 currencyPositivePrefix: " ", 60 currencyNegativePrefix: " ", 61 monthsAbbreviated: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, 62 monthsNarrow: []string{"", "जन", "फेब", "मार्च", "अप्र", "मे", "जुन", "जुल", "अग", "सेप", "अक्टो", "नोभे", "डिसे"}, 63 monthsWide: []string{"", "जनवरी", "फेब्रुअरी", "मार्च", "अप्रिल", "मे", "जुन", "जुलाई", "अगस्ट", "सेप्टेम्बर", "अक्टोबर", "नोभेम्बर", "डिसेम्बर"}, 64 daysAbbreviated: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, 65 daysNarrow: []string{"आ", "सो", "म", "बु", "बि", "शु", "श"}, 66 daysShort: []string{"आइत", "सोम", "मङ्गल", "बुध", "बिहि", "शुक्र", "शनि"}, 67 daysWide: []string{"आइतबार", "सोमबार", "मङ्गलबार", "बुधबार", "बिहिबार", "शुक्रबार", "शनिबार"}, 68 periodsAbbreviated: []string{"पूर्वाह्न", "अपराह्न"}, 69 periodsNarrow: []string{"पूर्वाह्न", "अपराह्न"}, 70 periodsWide: []string{"पूर्वाह्न", "अपराह्न"}, 71 erasAbbreviated: []string{"ईसा पूर्व", "सन्"}, 72 erasNarrow: []string{"", ""}, 73 erasWide: []string{"ईसा पूर्व", "सन्"}, 74 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": "केन्द्रीय इन्डोनेशिया समय", "∅∅∅": "ब्राजिलीया ग्रीष्मकालीन समय"}, 75 } 76} 77 78// Locale returns the current translators string locale 79func (ne *ne) Locale() string { 80 return ne.locale 81} 82 83// PluralsCardinal returns the list of cardinal plural rules associated with 'ne' 84func (ne *ne) PluralsCardinal() []locales.PluralRule { 85 return ne.pluralsCardinal 86} 87 88// PluralsOrdinal returns the list of ordinal plural rules associated with 'ne' 89func (ne *ne) PluralsOrdinal() []locales.PluralRule { 90 return ne.pluralsOrdinal 91} 92 93// PluralsRange returns the list of range plural rules associated with 'ne' 94func (ne *ne) PluralsRange() []locales.PluralRule { 95 return ne.pluralsRange 96} 97 98// CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'ne' 99func (ne *ne) 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 'ne' 111func (ne *ne) OrdinalPluralRule(num float64, v uint64) locales.PluralRule { 112 113 n := math.Abs(num) 114 115 if n >= 1 && n <= 4 { 116 return locales.PluralRuleOne 117 } 118 119 return locales.PluralRuleOther 120} 121 122// RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'ne' 123func (ne *ne) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule { 124 125 start := ne.CardinalPluralRule(num1, v1) 126 end := ne.CardinalPluralRule(num2, v2) 127 128 if start == locales.PluralRuleOne && end == locales.PluralRuleOther { 129 return locales.PluralRuleOther 130 } else if start == locales.PluralRuleOther && end == locales.PluralRuleOne { 131 return locales.PluralRuleOne 132 } 133 134 return locales.PluralRuleOther 135 136} 137 138// MonthAbbreviated returns the locales abbreviated month given the 'month' provided 139func (ne *ne) MonthAbbreviated(month time.Month) string { 140 return ne.monthsAbbreviated[month] 141} 142 143// MonthsAbbreviated returns the locales abbreviated months 144func (ne *ne) MonthsAbbreviated() []string { 145 return ne.monthsAbbreviated[1:] 146} 147 148// MonthNarrow returns the locales narrow month given the 'month' provided 149func (ne *ne) MonthNarrow(month time.Month) string { 150 return ne.monthsNarrow[month] 151} 152 153// MonthsNarrow returns the locales narrow months 154func (ne *ne) MonthsNarrow() []string { 155 return ne.monthsNarrow[1:] 156} 157 158// MonthWide returns the locales wide month given the 'month' provided 159func (ne *ne) MonthWide(month time.Month) string { 160 return ne.monthsWide[month] 161} 162 163// MonthsWide returns the locales wide months 164func (ne *ne) MonthsWide() []string { 165 return ne.monthsWide[1:] 166} 167 168// WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided 169func (ne *ne) WeekdayAbbreviated(weekday time.Weekday) string { 170 return ne.daysAbbreviated[weekday] 171} 172 173// WeekdaysAbbreviated returns the locales abbreviated weekdays 174func (ne *ne) WeekdaysAbbreviated() []string { 175 return ne.daysAbbreviated 176} 177 178// WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided 179func (ne *ne) WeekdayNarrow(weekday time.Weekday) string { 180 return ne.daysNarrow[weekday] 181} 182 183// WeekdaysNarrow returns the locales narrow weekdays 184func (ne *ne) WeekdaysNarrow() []string { 185 return ne.daysNarrow 186} 187 188// WeekdayShort returns the locales short weekday given the 'weekday' provided 189func (ne *ne) WeekdayShort(weekday time.Weekday) string { 190 return ne.daysShort[weekday] 191} 192 193// WeekdaysShort returns the locales short weekdays 194func (ne *ne) WeekdaysShort() []string { 195 return ne.daysShort 196} 197 198// WeekdayWide returns the locales wide weekday given the 'weekday' provided 199func (ne *ne) WeekdayWide(weekday time.Weekday) string { 200 return ne.daysWide[weekday] 201} 202 203// WeekdaysWide returns the locales wide weekdays 204func (ne *ne) WeekdaysWide() []string { 205 return ne.daysWide 206} 207 208// Decimal returns the decimal point of number 209func (ne *ne) Decimal() string { 210 return ne.decimal 211} 212 213// Group returns the group of number 214func (ne *ne) Group() string { 215 return ne.group 216} 217 218// Group returns the minus sign of number 219func (ne *ne) Minus() string { 220 return ne.minus 221} 222 223// FmtNumber returns 'num' with digits/precision of 'v' for 'ne' and handles both Whole and Real numbers based on 'v' 224func (ne *ne) FmtNumber(num float64, v uint64) string { 225 226 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 227 l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3 228 count := 0 229 inWhole := v == 0 230 b := make([]byte, 0, l) 231 232 for i := len(s) - 1; i >= 0; i-- { 233 234 if s[i] == '.' { 235 b = append(b, ne.decimal[0]) 236 inWhole = true 237 continue 238 } 239 240 if inWhole { 241 if count == 3 { 242 b = append(b, ne.group[0]) 243 count = 1 244 } else { 245 count++ 246 } 247 } 248 249 b = append(b, s[i]) 250 } 251 252 if num < 0 { 253 b = append(b, ne.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 'ne' and handles both Whole and Real numbers based on 'v' 265// NOTE: 'num' passed into FmtPercent is assumed to be in percent already 266func (ne *ne) 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, ne.decimal[0]) 275 continue 276 } 277 278 b = append(b, s[i]) 279 } 280 281 if num < 0 { 282 b = append(b, ne.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, ne.percent...) 291 292 return string(b) 293} 294 295// FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'ne' 296func (ne *ne) FmtCurrency(num float64, v uint64, currency currency.Type) string { 297 298 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 299 symbol := ne.currencies[currency] 300 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 301 count := 0 302 inWhole := v == 0 303 b := make([]byte, 0, l) 304 305 for i := len(s) - 1; i >= 0; i-- { 306 307 if s[i] == '.' { 308 b = append(b, ne.decimal[0]) 309 inWhole = true 310 continue 311 } 312 313 if inWhole { 314 if count == 3 { 315 b = append(b, ne.group[0]) 316 count = 1 317 } else { 318 count++ 319 } 320 } 321 322 b = append(b, s[i]) 323 } 324 325 for j := len(symbol) - 1; j >= 0; j-- { 326 b = append(b, symbol[j]) 327 } 328 329 for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { 330 b = append(b, ne.currencyPositivePrefix[j]) 331 } 332 333 if num < 0 { 334 b = append(b, ne.minus[0]) 335 } 336 337 // reverse 338 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 339 b[i], b[j] = b[j], b[i] 340 } 341 342 if int(v) < 2 { 343 344 if v == 0 { 345 b = append(b, ne.decimal...) 346 } 347 348 for i := 0; i < 2-int(v); i++ { 349 b = append(b, '0') 350 } 351 } 352 353 return string(b) 354} 355 356// FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'ne' 357// in accounting notation. 358func (ne *ne) FmtAccounting(num float64, v uint64, currency currency.Type) string { 359 360 s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64) 361 symbol := ne.currencies[currency] 362 l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3 363 count := 0 364 inWhole := v == 0 365 b := make([]byte, 0, l) 366 367 for i := len(s) - 1; i >= 0; i-- { 368 369 if s[i] == '.' { 370 b = append(b, ne.decimal[0]) 371 inWhole = true 372 continue 373 } 374 375 if inWhole { 376 if count == 3 { 377 b = append(b, ne.group[0]) 378 count = 1 379 } else { 380 count++ 381 } 382 } 383 384 b = append(b, s[i]) 385 } 386 387 if num < 0 { 388 389 for j := len(symbol) - 1; j >= 0; j-- { 390 b = append(b, symbol[j]) 391 } 392 393 for j := len(ne.currencyNegativePrefix) - 1; j >= 0; j-- { 394 b = append(b, ne.currencyNegativePrefix[j]) 395 } 396 397 b = append(b, ne.minus[0]) 398 399 } else { 400 401 for j := len(symbol) - 1; j >= 0; j-- { 402 b = append(b, symbol[j]) 403 } 404 405 for j := len(ne.currencyPositivePrefix) - 1; j >= 0; j-- { 406 b = append(b, ne.currencyPositivePrefix[j]) 407 } 408 409 } 410 411 // reverse 412 for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 413 b[i], b[j] = b[j], b[i] 414 } 415 416 if int(v) < 2 { 417 418 if v == 0 { 419 b = append(b, ne.decimal...) 420 } 421 422 for i := 0; i < 2-int(v); i++ { 423 b = append(b, '0') 424 } 425 } 426 427 return string(b) 428} 429 430// FmtDateShort returns the short date representation of 't' for 'ne' 431func (ne *ne) FmtDateShort(t time.Time) string { 432 433 b := make([]byte, 0, 32) 434 435 if t.Year() > 9 { 436 b = append(b, strconv.Itoa(t.Year())[2:]...) 437 } else { 438 b = append(b, strconv.Itoa(t.Year())[1:]...) 439 } 440 441 b = append(b, []byte{0x2f}...) 442 b = strconv.AppendInt(b, int64(t.Month()), 10) 443 b = append(b, []byte{0x2f}...) 444 b = strconv.AppendInt(b, int64(t.Day()), 10) 445 446 return string(b) 447} 448 449// FmtDateMedium returns the medium date representation of 't' for 'ne' 450func (ne *ne) FmtDateMedium(t time.Time) string { 451 452 b := make([]byte, 0, 32) 453 454 if t.Year() > 0 { 455 b = strconv.AppendInt(b, int64(t.Year()), 10) 456 } else { 457 b = strconv.AppendInt(b, int64(-t.Year()), 10) 458 } 459 460 b = append(b, []byte{0x20}...) 461 b = append(b, ne.monthsAbbreviated[t.Month()]...) 462 b = append(b, []byte{0x20}...) 463 b = strconv.AppendInt(b, int64(t.Day()), 10) 464 465 return string(b) 466} 467 468// FmtDateLong returns the long date representation of 't' for 'ne' 469func (ne *ne) FmtDateLong(t time.Time) string { 470 471 b := make([]byte, 0, 32) 472 473 if t.Year() > 0 { 474 b = strconv.AppendInt(b, int64(t.Year()), 10) 475 } else { 476 b = strconv.AppendInt(b, int64(-t.Year()), 10) 477 } 478 479 b = append(b, []byte{0x20}...) 480 b = append(b, ne.monthsWide[t.Month()]...) 481 b = append(b, []byte{0x20}...) 482 b = strconv.AppendInt(b, int64(t.Day()), 10) 483 484 return string(b) 485} 486 487// FmtDateFull returns the full date representation of 't' for 'ne' 488func (ne *ne) FmtDateFull(t time.Time) string { 489 490 b := make([]byte, 0, 32) 491 492 if t.Year() > 0 { 493 b = strconv.AppendInt(b, int64(t.Year()), 10) 494 } else { 495 b = strconv.AppendInt(b, int64(-t.Year()), 10) 496 } 497 498 b = append(b, []byte{0x20}...) 499 b = append(b, ne.monthsWide[t.Month()]...) 500 b = append(b, []byte{0x20}...) 501 b = strconv.AppendInt(b, int64(t.Day()), 10) 502 b = append(b, []byte{0x2c, 0x20}...) 503 b = append(b, ne.daysWide[t.Weekday()]...) 504 505 return string(b) 506} 507 508// FmtTimeShort returns the short time representation of 't' for 'ne' 509func (ne *ne) FmtTimeShort(t time.Time) string { 510 511 b := make([]byte, 0, 32) 512 513 if t.Hour() < 10 { 514 b = append(b, '0') 515 } 516 517 b = strconv.AppendInt(b, int64(t.Hour()), 10) 518 b = append(b, ne.timeSeparator...) 519 520 if t.Minute() < 10 { 521 b = append(b, '0') 522 } 523 524 b = strconv.AppendInt(b, int64(t.Minute()), 10) 525 526 return string(b) 527} 528 529// FmtTimeMedium returns the medium time representation of 't' for 'ne' 530func (ne *ne) FmtTimeMedium(t time.Time) string { 531 532 b := make([]byte, 0, 32) 533 534 if t.Hour() < 10 { 535 b = append(b, '0') 536 } 537 538 b = strconv.AppendInt(b, int64(t.Hour()), 10) 539 b = append(b, ne.timeSeparator...) 540 541 if t.Minute() < 10 { 542 b = append(b, '0') 543 } 544 545 b = strconv.AppendInt(b, int64(t.Minute()), 10) 546 b = append(b, ne.timeSeparator...) 547 548 if t.Second() < 10 { 549 b = append(b, '0') 550 } 551 552 b = strconv.AppendInt(b, int64(t.Second()), 10) 553 554 return string(b) 555} 556 557// FmtTimeLong returns the long time representation of 't' for 'ne' 558func (ne *ne) FmtTimeLong(t time.Time) string { 559 560 b := make([]byte, 0, 32) 561 562 if t.Hour() < 10 { 563 b = append(b, '0') 564 } 565 566 b = strconv.AppendInt(b, int64(t.Hour()), 10) 567 b = append(b, ne.timeSeparator...) 568 569 if t.Minute() < 10 { 570 b = append(b, '0') 571 } 572 573 b = strconv.AppendInt(b, int64(t.Minute()), 10) 574 b = append(b, ne.timeSeparator...) 575 576 if t.Second() < 10 { 577 b = append(b, '0') 578 } 579 580 b = strconv.AppendInt(b, int64(t.Second()), 10) 581 b = append(b, []byte{0x20}...) 582 583 tz, _ := t.Zone() 584 b = append(b, tz...) 585 586 return string(b) 587} 588 589// FmtTimeFull returns the full time representation of 't' for 'ne' 590func (ne *ne) FmtTimeFull(t time.Time) string { 591 592 b := make([]byte, 0, 32) 593 594 if t.Hour() < 10 { 595 b = append(b, '0') 596 } 597 598 b = strconv.AppendInt(b, int64(t.Hour()), 10) 599 b = append(b, ne.timeSeparator...) 600 601 if t.Minute() < 10 { 602 b = append(b, '0') 603 } 604 605 b = strconv.AppendInt(b, int64(t.Minute()), 10) 606 b = append(b, ne.timeSeparator...) 607 608 if t.Second() < 10 { 609 b = append(b, '0') 610 } 611 612 b = strconv.AppendInt(b, int64(t.Second()), 10) 613 b = append(b, []byte{0x20}...) 614 615 tz, _ := t.Zone() 616 617 if btz, ok := ne.timezones[tz]; ok { 618 b = append(b, btz...) 619 } else { 620 b = append(b, tz...) 621 } 622 623 return string(b) 624} 625