dz_BT.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. package dz_BT
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type dz_BT struct {
  10. locale string
  11. pluralsCardinal []locales.PluralRule
  12. pluralsOrdinal []locales.PluralRule
  13. pluralsRange []locales.PluralRule
  14. decimal string
  15. group string
  16. minus string
  17. percent string
  18. percentSuffix string
  19. perMille string
  20. timeSeparator string
  21. inifinity string
  22. currencies []string // idx = enum of currency code
  23. monthsAbbreviated []string
  24. monthsNarrow []string
  25. monthsWide []string
  26. daysAbbreviated []string
  27. daysNarrow []string
  28. daysShort []string
  29. daysWide []string
  30. periodsAbbreviated []string
  31. periodsNarrow []string
  32. periodsShort []string
  33. periodsWide []string
  34. erasAbbreviated []string
  35. erasNarrow []string
  36. erasWide []string
  37. timezones map[string]string
  38. }
  39. // New returns a new instance of translator for the 'dz_BT' locale
  40. func New() locales.Translator {
  41. return &dz_BT{
  42. locale: "dz_BT",
  43. pluralsCardinal: []locales.PluralRule{6},
  44. pluralsOrdinal: nil,
  45. pluralsRange: nil,
  46. decimal: ".",
  47. group: ",",
  48. minus: "-",
  49. percent: "%",
  50. perMille: "‰",
  51. timeSeparator: ":",
  52. inifinity: "གྲངས་མེད",
  53. 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", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "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", "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"},
  54. percentSuffix: " ",
  55. monthsAbbreviated: []string{"", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩", "༡༠", "༡༡", "12"},
  56. monthsNarrow: []string{"", "༡", "༢", "༣", "4", "༥", "༦", "༧", "༨", "9", "༡༠", "༡༡", "༡༢"},
  57. monthsWide: []string{"", "ཟླ་དངཔ་", "ཟླ་གཉིས་པ་", "ཟླ་གསུམ་པ་", "ཟླ་བཞི་པ་", "ཟླ་ལྔ་པ་", "ཟླ་དྲུག་པ", "ཟླ་བདུན་པ་", "ཟླ་བརྒྱད་པ་", "ཟླ་དགུ་པ་", "ཟླ་བཅུ་པ་", "ཟླ་བཅུ་གཅིག་པ་", "ཟླ་བཅུ་གཉིས་པ་"},
  58. daysAbbreviated: []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"},
  59. daysNarrow: []string{"ཟླ", "མིར", "ལྷག", "ཕུར", "སངྶ", "སྤེན", "ཉི"},
  60. daysShort: []string{"ཟླ་", "མིར་", "ལྷག་", "ཕུར་", "སངས་", "སྤེན་", "ཉི་"},
  61. daysWide: []string{"གཟའ་ཟླ་བ་", "གཟའ་མིག་དམར་", "གཟའ་ལྷག་པ་", "གཟའ་ཕུར་བུ་", "གཟའ་པ་སངས་", "གཟའ་སྤེན་པ་", "གཟའ་ཉི་མ་"},
  62. periodsAbbreviated: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"},
  63. periodsNarrow: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"},
  64. periodsWide: []string{"སྔ་ཆ་", "ཕྱི་ཆ་"},
  65. erasAbbreviated: []string{"BCE", "CE"},
  66. erasNarrow: []string{"", ""},
  67. erasWide: []string{"", ""},
  68. timezones: map[string]string{"GMT": "གིརིན་ཝིཆ་ལུ་ཡོད་པའི་ཆུ་ཚོད", "HECU": "ཀིའུ་བྷ་ཉིན་སྲུང་ཆུ་ཚོད", "LHST": "LHST", "MDT": "MDT", "TMT": "TMT", "ARST": "ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "AWST": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "COT": "ཀོ་ལོམ་བྷི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "OEZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "AST": "ཨེཊ་ལེན་ཊིཀ་ཚད་ལྡན་ཆུ་ཚོད", "BOT": "བྷོ་ལི་བི་ཡ་ཆུ་ཚོད", "IST": "རྒྱ་གར་ཆུ་ཚོད", "MST": "MST", "SRT": "སུ་རི་ནཱམ་ཆུ་ཚོད", "EAT": "ཤར་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "CLT": "ཅི་ལི་ཚད་ལྡན་ཆུ་ཚོད", "ART": "ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "AEDT": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "AKDT": "ཨ་ལསི་ཀ་ཉིན་སྲུང་ཆུ་ཚོད", "EDT": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "∅∅∅": "ཨེ་མ་ཛཱོན་བྱཱར་དུས་ཆུ་ཚོད", "JDT": "ཇ་པཱན་ཉིན་སྲུང་ཆུ་ཚོད", "BT": "འབྲུག་ཡུལ་ཆུ་ཚོད", "HEOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "EST": "བྱང་ཨ་མི་རི་ཀ་ཤར་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "MESZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "ChST": "ChST", "MEZ": "དབུས་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "HEPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཉིན་སྲུང་ཆུ་ཚོད", "TMST": "TMST", "JST": "ཇ་པཱན་ཚད་ལྡན་ཆུ་ཚོད", "HNT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "VET": "བེ་ནི་ཛུ་ཝེ་ལ་ཆུ་ཚོད", "CST": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཚད་ལྡན་ཆུ་ཚོད", "AEST": "ཤར་ཕྱོགས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "AKST": "ཨ་ལསི་ཀ་ཚད་ལྡན་ཆུ་ཚོད", "HNEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "ACST": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "HNPM": "པའི་རི་དང་མི་ཀི་ལཱོན་ཚད་ལྡན་ཆུ་ཚོད", "WIT": "ཤར་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "GYT": "གུ་ཡ་ན་ཆུ་ཚོད", "GFT": "ཕིརེནཅ་གི་ཡ་ན་ཆུ་ཚོད", "ACDT": "དབུས་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "ADT": "ཨེཊ་ལེན་ཊིཀ་ཉིན་སྲུང་ཆུ་ཚོད", "WEZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་ཚད་ལྡན་ཆུ་ཚོད", "WESZ": "ནུབ་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "HEEG": "ཤར་ཕྱོགས་གིརིན་ལེནཌ་བྱཱར་དུས་ཆུ་ཚོད", "ACWST": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཚད་ལྡན་ཆུ་ཚོད", "WART": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་ཚད་ལྡན་ཆུ་ཚོད", "HNNOMX": "HNNOMX", "COST": "ཀོ་ལོམ་བྷི་ཡ་བྱཱར་དུས་ཆུ་ཚོད", "HEPMX": "HEPMX", "WIB": "ནུབ་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "WAT": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཚད་ལྡན་ཆུ་ཚོད", "NZDT": "ནིའུ་ཛི་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "HNOG": "ནུབ་ཕྱོགས་གིརིན་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "HKST": "HKST", "WARST": "ནུབ་ཕྱོགས་ཨར་ཇེན་ཊི་ན་བྱཱར་དུས་ཆུ་ཚོད", "CAT": "དབུས་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "UYT": "ཡུ་རུ་གུ་ཝཱའི་ཚད་ལྡན་ཆུ་ཚོད", "CHAST": "CHAST", "CDT": "བྱང་ཨ་མི་རི་ཀ་དབུས་ཕྱོགས་ཉིན་སྲུང་ཆུ་ཚོད", "WAST": "ནུབ་ཕྱོགས་ཨཕ་རི་ཀཱ་བྱཱར་དུས་ཆུ་ཚོད", "SGT": "SGT", "WITA": "དབུས་ཕྱོགས་ཨིན་ཌོ་ནེ་ཤི་ཡ་ཆུ་ཚོད", "HAT": "ནིའུ་ཕའུནཌ་ལེནཌ་ཉིན་སྲུང་ཆུ་ཚོད", "CLST": "ཅི་ལི་བྱཱར་དུས་ཆུ་ཚོད", "UYST": "ཡུ་རུ་གུ་ཝཱའི་བྱཱར་དུས་ཆུ་ཚོད", "PST": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཚད་ལྡན་ཆུ་ཚོད", "SAST": "ལྷོ་ཕྱོགས་ཨཕ་རི་ཀཱ་ཆུ་ཚོད", "ECT": "ཨེ་ཀུ་ཌཽ་ཆུ་ཚོད", "AWDT": "ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "NZST": "ནིའུ་ཛི་ལེནཌ་ཚད་ལྡན་ཆུ་ཚོད", "OESZ": "ཤར་ཕྱོགས་ཡུ་རོ་པེན་བྱཱར་དུས་ཆུ་ཚོད", "HAST": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཚད་ལྡན་ཆུ་ཚོད", "CHADT": "CHADT", "HNCU": "ཀིའུ་བྷ་ཚད་ལྡན་ཆུ་ཚོད", "HNPMX": "HNPMX", "PDT": "བྱང་ཨ་མི་རི་ཀ་པེ་སི་ཕིག་ཉིན་སྲུང་ཆུ་ཚོད", "MYT": "MYT", "LHDT": "LHDT", "HENOMX": "HENOMX", "HADT": "ཧ་ཝའི་-ཨེ་ལིའུ་ཤེན་ཉིན་སྲུང་ཆུ་ཚོད", "ACWDT": "དབུས་ནུབ་ཕྱོགས་ཨཱོས་ཊྲེལ་ལི་ཡ་ཉིན་སྲུང་ཆུ་ཚོད", "HKT": "HKT"},
  69. }
  70. }
  71. // Locale returns the current translators string locale
  72. func (dz *dz_BT) Locale() string {
  73. return dz.locale
  74. }
  75. // PluralsCardinal returns the list of cardinal plural rules associated with 'dz_BT'
  76. func (dz *dz_BT) PluralsCardinal() []locales.PluralRule {
  77. return dz.pluralsCardinal
  78. }
  79. // PluralsOrdinal returns the list of ordinal plural rules associated with 'dz_BT'
  80. func (dz *dz_BT) PluralsOrdinal() []locales.PluralRule {
  81. return dz.pluralsOrdinal
  82. }
  83. // PluralsRange returns the list of range plural rules associated with 'dz_BT'
  84. func (dz *dz_BT) PluralsRange() []locales.PluralRule {
  85. return dz.pluralsRange
  86. }
  87. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'dz_BT'
  88. func (dz *dz_BT) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  89. return locales.PluralRuleOther
  90. }
  91. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'dz_BT'
  92. func (dz *dz_BT) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  93. return locales.PluralRuleUnknown
  94. }
  95. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'dz_BT'
  96. func (dz *dz_BT) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  97. return locales.PluralRuleUnknown
  98. }
  99. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  100. func (dz *dz_BT) MonthAbbreviated(month time.Month) string {
  101. return dz.monthsAbbreviated[month]
  102. }
  103. // MonthsAbbreviated returns the locales abbreviated months
  104. func (dz *dz_BT) MonthsAbbreviated() []string {
  105. return dz.monthsAbbreviated[1:]
  106. }
  107. // MonthNarrow returns the locales narrow month given the 'month' provided
  108. func (dz *dz_BT) MonthNarrow(month time.Month) string {
  109. return dz.monthsNarrow[month]
  110. }
  111. // MonthsNarrow returns the locales narrow months
  112. func (dz *dz_BT) MonthsNarrow() []string {
  113. return dz.monthsNarrow[1:]
  114. }
  115. // MonthWide returns the locales wide month given the 'month' provided
  116. func (dz *dz_BT) MonthWide(month time.Month) string {
  117. return dz.monthsWide[month]
  118. }
  119. // MonthsWide returns the locales wide months
  120. func (dz *dz_BT) MonthsWide() []string {
  121. return dz.monthsWide[1:]
  122. }
  123. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  124. func (dz *dz_BT) WeekdayAbbreviated(weekday time.Weekday) string {
  125. return dz.daysAbbreviated[weekday]
  126. }
  127. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  128. func (dz *dz_BT) WeekdaysAbbreviated() []string {
  129. return dz.daysAbbreviated
  130. }
  131. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  132. func (dz *dz_BT) WeekdayNarrow(weekday time.Weekday) string {
  133. return dz.daysNarrow[weekday]
  134. }
  135. // WeekdaysNarrow returns the locales narrow weekdays
  136. func (dz *dz_BT) WeekdaysNarrow() []string {
  137. return dz.daysNarrow
  138. }
  139. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  140. func (dz *dz_BT) WeekdayShort(weekday time.Weekday) string {
  141. return dz.daysShort[weekday]
  142. }
  143. // WeekdaysShort returns the locales short weekdays
  144. func (dz *dz_BT) WeekdaysShort() []string {
  145. return dz.daysShort
  146. }
  147. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  148. func (dz *dz_BT) WeekdayWide(weekday time.Weekday) string {
  149. return dz.daysWide[weekday]
  150. }
  151. // WeekdaysWide returns the locales wide weekdays
  152. func (dz *dz_BT) WeekdaysWide() []string {
  153. return dz.daysWide
  154. }
  155. // Decimal returns the decimal point of number
  156. func (dz *dz_BT) Decimal() string {
  157. return dz.decimal
  158. }
  159. // Group returns the group of number
  160. func (dz *dz_BT) Group() string {
  161. return dz.group
  162. }
  163. // Group returns the minus sign of number
  164. func (dz *dz_BT) Minus() string {
  165. return dz.minus
  166. }
  167. // FmtNumber returns 'num' with digits/precision of 'v' for 'dz_BT' and handles both Whole and Real numbers based on 'v'
  168. func (dz *dz_BT) FmtNumber(num float64, v uint64) string {
  169. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  170. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  171. count := 0
  172. inWhole := v == 0
  173. inSecondary := false
  174. groupThreshold := 3
  175. b := make([]byte, 0, l)
  176. for i := len(s) - 1; i >= 0; i-- {
  177. if s[i] == '.' {
  178. b = append(b, dz.decimal[0])
  179. inWhole = true
  180. continue
  181. }
  182. if inWhole {
  183. if count == groupThreshold {
  184. b = append(b, dz.group[0])
  185. count = 1
  186. if !inSecondary {
  187. inSecondary = true
  188. groupThreshold = 2
  189. }
  190. } else {
  191. count++
  192. }
  193. }
  194. b = append(b, s[i])
  195. }
  196. if num < 0 {
  197. b = append(b, dz.minus[0])
  198. }
  199. // reverse
  200. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  201. b[i], b[j] = b[j], b[i]
  202. }
  203. return string(b)
  204. }
  205. // FmtPercent returns 'num' with digits/precision of 'v' for 'dz_BT' and handles both Whole and Real numbers based on 'v'
  206. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  207. func (dz *dz_BT) FmtPercent(num float64, v uint64) string {
  208. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  209. l := len(s) + 5
  210. b := make([]byte, 0, l)
  211. for i := len(s) - 1; i >= 0; i-- {
  212. if s[i] == '.' {
  213. b = append(b, dz.decimal[0])
  214. continue
  215. }
  216. b = append(b, s[i])
  217. }
  218. if num < 0 {
  219. b = append(b, dz.minus[0])
  220. }
  221. // reverse
  222. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  223. b[i], b[j] = b[j], b[i]
  224. }
  225. b = append(b, dz.percentSuffix...)
  226. b = append(b, dz.percent...)
  227. return string(b)
  228. }
  229. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'dz_BT'
  230. func (dz *dz_BT) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  231. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  232. symbol := dz.currencies[currency]
  233. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  234. count := 0
  235. inWhole := v == 0
  236. inSecondary := false
  237. groupThreshold := 3
  238. b := make([]byte, 0, l)
  239. for i := len(s) - 1; i >= 0; i-- {
  240. if s[i] == '.' {
  241. b = append(b, dz.decimal[0])
  242. inWhole = true
  243. continue
  244. }
  245. if inWhole {
  246. if count == groupThreshold {
  247. b = append(b, dz.group[0])
  248. count = 1
  249. if !inSecondary {
  250. inSecondary = true
  251. groupThreshold = 2
  252. }
  253. } else {
  254. count++
  255. }
  256. }
  257. b = append(b, s[i])
  258. }
  259. for j := len(symbol) - 1; j >= 0; j-- {
  260. b = append(b, symbol[j])
  261. }
  262. if num < 0 {
  263. b = append(b, dz.minus[0])
  264. }
  265. // reverse
  266. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  267. b[i], b[j] = b[j], b[i]
  268. }
  269. if int(v) < 2 {
  270. if v == 0 {
  271. b = append(b, dz.decimal...)
  272. }
  273. for i := 0; i < 2-int(v); i++ {
  274. b = append(b, '0')
  275. }
  276. }
  277. return string(b)
  278. }
  279. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'dz_BT'
  280. // in accounting notation.
  281. func (dz *dz_BT) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  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. b := make([]byte, 0, l)
  290. for i := len(s) - 1; i >= 0; i-- {
  291. if s[i] == '.' {
  292. b = append(b, dz.decimal[0])
  293. inWhole = true
  294. continue
  295. }
  296. if inWhole {
  297. if count == groupThreshold {
  298. b = append(b, dz.group[0])
  299. count = 1
  300. if !inSecondary {
  301. inSecondary = true
  302. groupThreshold = 2
  303. }
  304. } else {
  305. count++
  306. }
  307. }
  308. b = append(b, s[i])
  309. }
  310. if num < 0 {
  311. for j := len(symbol) - 1; j >= 0; j-- {
  312. b = append(b, symbol[j])
  313. }
  314. b = append(b, dz.minus[0])
  315. } else {
  316. for j := len(symbol) - 1; j >= 0; j-- {
  317. b = append(b, symbol[j])
  318. }
  319. }
  320. // reverse
  321. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  322. b[i], b[j] = b[j], b[i]
  323. }
  324. if int(v) < 2 {
  325. if v == 0 {
  326. b = append(b, dz.decimal...)
  327. }
  328. for i := 0; i < 2-int(v); i++ {
  329. b = append(b, '0')
  330. }
  331. }
  332. return string(b)
  333. }
  334. // FmtDateShort returns the short date representation of 't' for 'dz_BT'
  335. func (dz *dz_BT) FmtDateShort(t time.Time) string {
  336. b := make([]byte, 0, 32)
  337. if t.Year() > 0 {
  338. b = strconv.AppendInt(b, int64(t.Year()), 10)
  339. } else {
  340. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  341. }
  342. b = append(b, []byte{0x2d}...)
  343. if t.Month() < 10 {
  344. b = append(b, '0')
  345. }
  346. b = strconv.AppendInt(b, int64(t.Month()), 10)
  347. b = append(b, []byte{0x2d}...)
  348. if t.Day() < 10 {
  349. b = append(b, '0')
  350. }
  351. b = strconv.AppendInt(b, int64(t.Day()), 10)
  352. return string(b)
  353. }
  354. // FmtDateMedium returns the medium date representation of 't' for 'dz_BT'
  355. func (dz *dz_BT) FmtDateMedium(t time.Time) string {
  356. b := make([]byte, 0, 32)
  357. 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}...)
  358. if t.Year() > 0 {
  359. b = strconv.AppendInt(b, int64(t.Year()), 10)
  360. } else {
  361. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  362. }
  363. b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9f, 0xe0, 0xbe, 0xb3, 0xe0, 0xbc, 0x8b}...)
  364. b = append(b, dz.monthsAbbreviated[t.Month()]...)
  365. b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
  366. if t.Day() < 10 {
  367. b = append(b, '0')
  368. }
  369. b = strconv.AppendInt(b, int64(t.Day()), 10)
  370. return string(b)
  371. }
  372. // FmtDateLong returns the long date representation of 't' for 'dz_BT'
  373. func (dz *dz_BT) FmtDateLong(t time.Time) string {
  374. b := make([]byte, 0, 32)
  375. 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}...)
  376. if t.Year() > 0 {
  377. b = strconv.AppendInt(b, int64(t.Year()), 10)
  378. } else {
  379. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  380. }
  381. b = append(b, []byte{0x20}...)
  382. b = append(b, dz.monthsWide[t.Month()]...)
  383. b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b, 0x20}...)
  384. if t.Day() < 10 {
  385. b = append(b, '0')
  386. }
  387. b = strconv.AppendInt(b, int64(t.Day()), 10)
  388. return string(b)
  389. }
  390. // FmtDateFull returns the full date representation of 't' for 'dz_BT'
  391. func (dz *dz_BT) FmtDateFull(t time.Time) string {
  392. b := make([]byte, 0, 32)
  393. b = append(b, dz.daysWide[t.Weekday()]...)
  394. 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}...)
  395. if t.Year() > 0 {
  396. b = strconv.AppendInt(b, int64(t.Year()), 10)
  397. } else {
  398. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  399. }
  400. b = append(b, []byte{0x20}...)
  401. b = append(b, dz.monthsWide[t.Month()]...)
  402. b = append(b, []byte{0x20, 0xe0, 0xbd, 0x9a, 0xe0, 0xbd, 0xba, 0xe0, 0xbd, 0xa6, 0xe0, 0xbc, 0x8b}...)
  403. if t.Day() < 10 {
  404. b = append(b, '0')
  405. }
  406. b = strconv.AppendInt(b, int64(t.Day()), 10)
  407. return string(b)
  408. }
  409. // FmtTimeShort returns the short time representation of 't' for 'dz_BT'
  410. func (dz *dz_BT) FmtTimeShort(t time.Time) string {
  411. b := make([]byte, 0, 32)
  412. 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}...)
  413. h := t.Hour()
  414. if h > 12 {
  415. h -= 12
  416. }
  417. b = strconv.AppendInt(b, int64(h), 10)
  418. b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)
  419. if t.Minute() < 10 {
  420. b = append(b, '0')
  421. }
  422. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  423. b = append(b, []byte{0x20}...)
  424. if t.Hour() < 12 {
  425. b = append(b, dz.periodsAbbreviated[0]...)
  426. } else {
  427. b = append(b, dz.periodsAbbreviated[1]...)
  428. }
  429. return string(b)
  430. }
  431. // FmtTimeMedium returns the medium time representation of 't' for 'dz_BT'
  432. func (dz *dz_BT) FmtTimeMedium(t time.Time) string {
  433. b := make([]byte, 0, 32)
  434. 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}...)
  435. h := t.Hour()
  436. if h > 12 {
  437. h -= 12
  438. }
  439. b = strconv.AppendInt(b, int64(h), 10)
  440. b = append(b, dz.timeSeparator...)
  441. if t.Minute() < 10 {
  442. b = append(b, '0')
  443. }
  444. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  445. b = append(b, dz.timeSeparator...)
  446. if t.Second() < 10 {
  447. b = append(b, '0')
  448. }
  449. b = strconv.AppendInt(b, int64(t.Second()), 10)
  450. b = append(b, []byte{0x20}...)
  451. if t.Hour() < 12 {
  452. b = append(b, dz.periodsAbbreviated[0]...)
  453. } else {
  454. b = append(b, dz.periodsAbbreviated[1]...)
  455. }
  456. return string(b)
  457. }
  458. // FmtTimeLong returns the long time representation of 't' for 'dz_BT'
  459. func (dz *dz_BT) FmtTimeLong(t time.Time) string {
  460. b := make([]byte, 0, 32)
  461. 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}...)
  462. h := t.Hour()
  463. if h > 12 {
  464. h -= 12
  465. }
  466. b = strconv.AppendInt(b, int64(h), 10)
  467. b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)
  468. if t.Minute() < 10 {
  469. b = append(b, '0')
  470. }
  471. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  472. b = append(b, dz.timeSeparator...)
  473. if t.Second() < 10 {
  474. b = append(b, '0')
  475. }
  476. b = strconv.AppendInt(b, int64(t.Second()), 10)
  477. b = append(b, []byte{0x20}...)
  478. if t.Hour() < 12 {
  479. b = append(b, dz.periodsAbbreviated[0]...)
  480. } else {
  481. b = append(b, dz.periodsAbbreviated[1]...)
  482. }
  483. b = append(b, []byte{0x20}...)
  484. tz, _ := t.Zone()
  485. b = append(b, tz...)
  486. return string(b)
  487. }
  488. // FmtTimeFull returns the full time representation of 't' for 'dz_BT'
  489. func (dz *dz_BT) FmtTimeFull(t time.Time) string {
  490. b := make([]byte, 0, 32)
  491. 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}...)
  492. h := t.Hour()
  493. if h > 12 {
  494. h -= 12
  495. }
  496. b = strconv.AppendInt(b, int64(h), 10)
  497. b = append(b, []byte{0x20, 0xe0, 0xbd, 0xa6, 0xe0, 0xbe, 0x90, 0xe0, 0xbd, 0xa2, 0xe0, 0xbc, 0x8b, 0xe0, 0xbd, 0x98, 0xe0, 0xbc, 0x8b, 0x20}...)
  498. if t.Minute() < 10 {
  499. b = append(b, '0')
  500. }
  501. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  502. b = append(b, dz.timeSeparator...)
  503. if t.Second() < 10 {
  504. b = append(b, '0')
  505. }
  506. b = strconv.AppendInt(b, int64(t.Second()), 10)
  507. b = append(b, []byte{0x20}...)
  508. if t.Hour() < 12 {
  509. b = append(b, dz.periodsAbbreviated[0]...)
  510. } else {
  511. b = append(b, dz.periodsAbbreviated[1]...)
  512. }
  513. b = append(b, []byte{0x20}...)
  514. tz, _ := t.Zone()
  515. if btz, ok := dz.timezones[tz]; ok {
  516. b = append(b, btz...)
  517. } else {
  518. b = append(b, tz...)
  519. }
  520. return string(b)
  521. }