km_KH.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. package km_KH
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type km_KH 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. perMille string
  19. timeSeparator string
  20. inifinity string
  21. currencies []string // idx = enum of currency code
  22. currencyNegativePrefix string
  23. currencyNegativeSuffix string
  24. monthsAbbreviated []string
  25. monthsNarrow []string
  26. monthsWide []string
  27. daysAbbreviated []string
  28. daysNarrow []string
  29. daysShort []string
  30. daysWide []string
  31. periodsAbbreviated []string
  32. periodsNarrow []string
  33. periodsShort []string
  34. periodsWide []string
  35. erasAbbreviated []string
  36. erasNarrow []string
  37. erasWide []string
  38. timezones map[string]string
  39. }
  40. // New returns a new instance of translator for the 'km_KH' locale
  41. func New() locales.Translator {
  42. return &km_KH{
  43. locale: "km_KH",
  44. pluralsCardinal: []locales.PluralRule{6},
  45. pluralsOrdinal: []locales.PluralRule{6},
  46. pluralsRange: []locales.PluralRule{6},
  47. decimal: ",",
  48. group: ".",
  49. minus: "-",
  50. percent: "%",
  51. perMille: "‰",
  52. timeSeparator: ":",
  53. inifinity: "∞",
  54. 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"},
  55. currencyNegativePrefix: "(",
  56. currencyNegativeSuffix: ")",
  57. monthsAbbreviated: []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"},
  58. monthsNarrow: []string{"", "ម", "ក", "ម", "ម", "ឧ", "ម", "ក", "ស", "ក", "ត", "វ", "ធ"},
  59. monthsWide: []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"},
  60. daysAbbreviated: []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"},
  61. daysNarrow: []string{"អ", "ច", "អ", "ព", "ព", "ស", "ស"},
  62. daysShort: []string{"អា", "ច", "អ", "ពុ", "ព្រ", "សុ", "ស"},
  63. daysWide: []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"},
  64. periodsAbbreviated: []string{"AM", "PM"},
  65. periodsNarrow: []string{"a", "p"},
  66. periodsWide: []string{"AM", "PM"},
  67. erasAbbreviated: []string{"មុន គ.ស.", "គ.ស."},
  68. erasNarrow: []string{"", ""},
  69. erasWide: []string{"មុន\u200bគ្រិស្តសករាជ", "គ្រិស្តសករាជ"},
  70. timezones: map[string]string{"EST": "ម៉ោងស្តង់ដារនៅទ្វីបអាមេរិកខាងជើងភាគខាងកើត", "ACWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "CLST": "ម៉ោងនៅស៊ីលីនារដូវក្តៅ", "OESZ": "ម៉ោង\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200bនា\u200bរដូវ\u200bក្ដៅ", "CHAST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bចាថាំ", "AEDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "BT": "ម៉ោងនៅប៊ូតង់", "NZDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bនូវែលសេឡង់", "HNPMX": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bប៉ាស៊ីហ្វិក\u200bម៉ិកស៊ិក", "MEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាល", "HEPM": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "WITA": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200b\u200bកណ្ដាល", "AKST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាឡាស្កា", "EDT": "ម៉ោងពេលថ្ងៃនៅទ្វីបអាមេរិកខាងជើងភាគខាងកើត", "IST": "ម៉ោង\u200bស្តង់ដារនៅ\u200bឥណ្ឌា", "HNT": "ម៉ោង\u200b\u200bស្តង់ដារ\u200b\u200bនៅ\u200bញូវហ្វោនឡែន", "COST": "ម៉ោង\u200bនៅ\u200bកូឡុំប៊ីនា\u200bរដូវ\u200bក្ដៅ", "AWST": "ម៉ោង\u200b\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "ADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអាត្លង់ទិក", "WESZ": "ម៉ោង\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិចនារដូវ\u200bក្ដៅ\u200b", "LHDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bឡតហៅ", "HNPM": "ម៉ោង\u200bស្តង់ដារ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "BOT": "ម៉ោង\u200bនៅ\u200bបូលីវី", "GFT": "ម៉ោង\u200bនៅ\u200bហ្គីយ៉ាន\u200bបារាំង", "MESZ": "ម៉ោង\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាលនា\u200bរដូវ\u200bក្ដៅ", "HKT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bហុងកុង", "HAT": "ម៉ោង\u200bពេលថ្ងៃ\u200bនៅ\u200bញូវហ្វោនឡែន", "MDT": "MDT", "COT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bកូឡុំប៊ី", "CHADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bចាថាំ", "ECT": "ម៉ោង\u200bនៅ\u200bអេក្វាទ័រ", "HKST": "ម៉ោងនៅ\u200bហុងកុងនា\u200bរដូវ\u200bក្ដៅ\u200b", "CAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bកណ្ដាល", "OEZ": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200b", "AKDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bអាឡាស្កា", "HEEG": "ម៉ោង\u200bនៅ\u200bហ្គ្រីនលែនខាង\u200bកើតនា\u200bរដូវ\u200bក្ដៅ", "PDT": "ម៉ោង\u200b\u200bពេលថ្ងៃនៅទ្វីប\u200bអាមរិក\u200bខាង\u200bជើងភាគខាងលិច", "SAST": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bត្បូង", "NZST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bនូវែលសេឡង់", "WART": "ម៉ោងស្តង់ដារ\u200bនៅ\u200bអាហ្សង់ទីនភាគខាងលិច", "EAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bកើត", "CLT": "ម៉ោងស្តង់ដារនៅស៊ីលី", "UYT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអ៊ុយរូហ្គាយ", "HNCU": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bគុយបា", "WARST": "ម៉ោង\u200bនៅ\u200bអាហ្សង់ទីនភាគខាងលិចនារដូវក្តៅ", "ACST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "ACWST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "MST": "MST", "PST": "ម៉ោងស្តង់ដារ\u200b\u200b\u200bនៅទ្វីប\u200bអាមរិក\u200bខាង\u200bជើងភាគខាងលិច", "WEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិច", "MYT": "ម៉ោង\u200bនៅ\u200bម៉ាឡេស៊ី", "WIB": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bលិច", "HEOG": "ម៉ោងនៅហ្គ្រីនលែនខាងលិចនារដូវក្តៅ", "HAST": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "ARST": "ម៉ោង\u200bនៅ\u200bអាហ្សង់ទីននារដូវក្តៅ", "ChST": "ម៉ោង\u200bស្តង់ដារនៅ\u200bចាំម៉ូរ៉ូ", "AST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាត្លង់ទិក", "JDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅជប៉ុន", "HNOG": "ម៉ោងស្តង់ដារនៅហ្គ្រីនលែនខាងលិច", "HNNOMX": "ម៉ោង\u200bស្តង់ដារនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "SRT": "ម៉ោង\u200bនៅ\u200bសូរីណាម", "TMST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bតួកម៉េនីស្ថាន\u200b", "ART": "ម៉ោងស្តង់ដារ\u200bនៅ\u200bអាហ្សង់ទីន", "ACDT": "ម៉ោង\u200bពេលថ្ងៃ\u200b\u200b\u200b\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "HNEG": "ម៉ោង\u200b\u200b\u200bស្តង់ដារ\u200bនៅ\u200b\u200bហ្គ្រីនលែន\u200bខាង\u200bកើត", "VET": "ម៉ោង\u200bនៅ\u200bវ៉េណេស៊ុយអេឡា", "UYST": "ម៉ោង\u200bនៅ\u200bអ៊ុយរូហ្គាយនា\u200b\u200bរដូវ\u200bក្ដៅ", "CST": "ម៉ោង\u200b\u200bស្តង់ដារនៅ\u200bទ្វីបអាមេរិក\u200bខាង\u200bជើងភាគកណ្តាល", "AEST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "JST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bជប៉ុន", "WAST": "ម៉ោងនៅ\u200bអាហ្វ្រិក\u200b\u200b\u200bខាងលិច\u200b\u200bនារដូវ\u200bក្ដៅ\u200b", "WIT": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bកើត", "∅∅∅": "ម៉ោង\u200bនៅ\u200bអាម៉ាហ្សូននារដូវក្តៅ", "GYT": "ម៉ោង\u200bនៅ\u200bហ្គីយ៉ាន", "AWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "CDT": "ម៉ោង\u200b\u200bពេលថ្ងៃនៅ\u200bទ្វីបអាមេរិក\u200bខាង\u200bជើងភាគកណ្តាល", "WAT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bលិច", "HENOMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "TMT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅតួកម៉េនីស្ថាន", "HADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "GMT": "ម៉ោងនៅគ្រីនវិច", "HECU": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bគុយបា", "HEPMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bប៉ាស៊ីហ្វិក\u200bម៉ិកស៊ិក", "SGT": "ម៉ោង\u200bនៅ\u200bសិង្ហបូរី", "LHST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bឡត\u200bហៅ"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (km *km_KH) Locale() string {
  75. return km.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'km_KH'
  78. func (km *km_KH) PluralsCardinal() []locales.PluralRule {
  79. return km.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'km_KH'
  82. func (km *km_KH) PluralsOrdinal() []locales.PluralRule {
  83. return km.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'km_KH'
  86. func (km *km_KH) PluralsRange() []locales.PluralRule {
  87. return km.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'km_KH'
  90. func (km *km_KH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. return locales.PluralRuleOther
  92. }
  93. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'km_KH'
  94. func (km *km_KH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  95. return locales.PluralRuleOther
  96. }
  97. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'km_KH'
  98. func (km *km_KH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  99. return locales.PluralRuleOther
  100. }
  101. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  102. func (km *km_KH) MonthAbbreviated(month time.Month) string {
  103. return km.monthsAbbreviated[month]
  104. }
  105. // MonthsAbbreviated returns the locales abbreviated months
  106. func (km *km_KH) MonthsAbbreviated() []string {
  107. return km.monthsAbbreviated[1:]
  108. }
  109. // MonthNarrow returns the locales narrow month given the 'month' provided
  110. func (km *km_KH) MonthNarrow(month time.Month) string {
  111. return km.monthsNarrow[month]
  112. }
  113. // MonthsNarrow returns the locales narrow months
  114. func (km *km_KH) MonthsNarrow() []string {
  115. return km.monthsNarrow[1:]
  116. }
  117. // MonthWide returns the locales wide month given the 'month' provided
  118. func (km *km_KH) MonthWide(month time.Month) string {
  119. return km.monthsWide[month]
  120. }
  121. // MonthsWide returns the locales wide months
  122. func (km *km_KH) MonthsWide() []string {
  123. return km.monthsWide[1:]
  124. }
  125. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  126. func (km *km_KH) WeekdayAbbreviated(weekday time.Weekday) string {
  127. return km.daysAbbreviated[weekday]
  128. }
  129. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  130. func (km *km_KH) WeekdaysAbbreviated() []string {
  131. return km.daysAbbreviated
  132. }
  133. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  134. func (km *km_KH) WeekdayNarrow(weekday time.Weekday) string {
  135. return km.daysNarrow[weekday]
  136. }
  137. // WeekdaysNarrow returns the locales narrow weekdays
  138. func (km *km_KH) WeekdaysNarrow() []string {
  139. return km.daysNarrow
  140. }
  141. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  142. func (km *km_KH) WeekdayShort(weekday time.Weekday) string {
  143. return km.daysShort[weekday]
  144. }
  145. // WeekdaysShort returns the locales short weekdays
  146. func (km *km_KH) WeekdaysShort() []string {
  147. return km.daysShort
  148. }
  149. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  150. func (km *km_KH) WeekdayWide(weekday time.Weekday) string {
  151. return km.daysWide[weekday]
  152. }
  153. // WeekdaysWide returns the locales wide weekdays
  154. func (km *km_KH) WeekdaysWide() []string {
  155. return km.daysWide
  156. }
  157. // Decimal returns the decimal point of number
  158. func (km *km_KH) Decimal() string {
  159. return km.decimal
  160. }
  161. // Group returns the group of number
  162. func (km *km_KH) Group() string {
  163. return km.group
  164. }
  165. // Group returns the minus sign of number
  166. func (km *km_KH) Minus() string {
  167. return km.minus
  168. }
  169. // FmtNumber returns 'num' with digits/precision of 'v' for 'km_KH' and handles both Whole and Real numbers based on 'v'
  170. func (km *km_KH) FmtNumber(num float64, v uint64) string {
  171. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  172. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  173. count := 0
  174. inWhole := v == 0
  175. b := make([]byte, 0, l)
  176. for i := len(s) - 1; i >= 0; i-- {
  177. if s[i] == '.' {
  178. b = append(b, km.decimal[0])
  179. inWhole = true
  180. continue
  181. }
  182. if inWhole {
  183. if count == 3 {
  184. b = append(b, km.group[0])
  185. count = 1
  186. } else {
  187. count++
  188. }
  189. }
  190. b = append(b, s[i])
  191. }
  192. if num < 0 {
  193. b = append(b, km.minus[0])
  194. }
  195. // reverse
  196. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  197. b[i], b[j] = b[j], b[i]
  198. }
  199. return string(b)
  200. }
  201. // FmtPercent returns 'num' with digits/precision of 'v' for 'km_KH' and handles both Whole and Real numbers based on 'v'
  202. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  203. func (km *km_KH) FmtPercent(num float64, v uint64) string {
  204. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  205. l := len(s) + 3
  206. b := make([]byte, 0, l)
  207. for i := len(s) - 1; i >= 0; i-- {
  208. if s[i] == '.' {
  209. b = append(b, km.decimal[0])
  210. continue
  211. }
  212. b = append(b, s[i])
  213. }
  214. if num < 0 {
  215. b = append(b, km.minus[0])
  216. }
  217. // reverse
  218. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  219. b[i], b[j] = b[j], b[i]
  220. }
  221. b = append(b, km.percent...)
  222. return string(b)
  223. }
  224. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'km_KH'
  225. func (km *km_KH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  226. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  227. symbol := km.currencies[currency]
  228. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  229. count := 0
  230. inWhole := v == 0
  231. b := make([]byte, 0, l)
  232. for i := len(s) - 1; i >= 0; i-- {
  233. if s[i] == '.' {
  234. b = append(b, km.decimal[0])
  235. inWhole = true
  236. continue
  237. }
  238. if inWhole {
  239. if count == 3 {
  240. b = append(b, km.group[0])
  241. count = 1
  242. } else {
  243. count++
  244. }
  245. }
  246. b = append(b, s[i])
  247. }
  248. if num < 0 {
  249. b = append(b, km.minus[0])
  250. }
  251. // reverse
  252. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  253. b[i], b[j] = b[j], b[i]
  254. }
  255. if int(v) < 2 {
  256. if v == 0 {
  257. b = append(b, km.decimal...)
  258. }
  259. for i := 0; i < 2-int(v); i++ {
  260. b = append(b, '0')
  261. }
  262. }
  263. b = append(b, symbol...)
  264. return string(b)
  265. }
  266. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'km_KH'
  267. // in accounting notation.
  268. func (km *km_KH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  269. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  270. symbol := km.currencies[currency]
  271. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  272. count := 0
  273. inWhole := v == 0
  274. b := make([]byte, 0, l)
  275. for i := len(s) - 1; i >= 0; i-- {
  276. if s[i] == '.' {
  277. b = append(b, km.decimal[0])
  278. inWhole = true
  279. continue
  280. }
  281. if inWhole {
  282. if count == 3 {
  283. b = append(b, km.group[0])
  284. count = 1
  285. } else {
  286. count++
  287. }
  288. }
  289. b = append(b, s[i])
  290. }
  291. if num < 0 {
  292. b = append(b, km.currencyNegativePrefix[0])
  293. }
  294. // reverse
  295. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  296. b[i], b[j] = b[j], b[i]
  297. }
  298. if int(v) < 2 {
  299. if v == 0 {
  300. b = append(b, km.decimal...)
  301. }
  302. for i := 0; i < 2-int(v); i++ {
  303. b = append(b, '0')
  304. }
  305. }
  306. if num < 0 {
  307. b = append(b, km.currencyNegativeSuffix...)
  308. b = append(b, symbol...)
  309. } else {
  310. b = append(b, symbol...)
  311. }
  312. return string(b)
  313. }
  314. // FmtDateShort returns the short date representation of 't' for 'km_KH'
  315. func (km *km_KH) FmtDateShort(t time.Time) string {
  316. b := make([]byte, 0, 32)
  317. b = strconv.AppendInt(b, int64(t.Day()), 10)
  318. b = append(b, []byte{0x2f}...)
  319. b = strconv.AppendInt(b, int64(t.Month()), 10)
  320. b = append(b, []byte{0x2f}...)
  321. if t.Year() > 9 {
  322. b = append(b, strconv.Itoa(t.Year())[2:]...)
  323. } else {
  324. b = append(b, strconv.Itoa(t.Year())[1:]...)
  325. }
  326. return string(b)
  327. }
  328. // FmtDateMedium returns the medium date representation of 't' for 'km_KH'
  329. func (km *km_KH) FmtDateMedium(t time.Time) string {
  330. b := make([]byte, 0, 32)
  331. b = strconv.AppendInt(b, int64(t.Day()), 10)
  332. b = append(b, []byte{0x20}...)
  333. b = append(b, km.monthsAbbreviated[t.Month()]...)
  334. b = append(b, []byte{0x20}...)
  335. if t.Year() > 0 {
  336. b = strconv.AppendInt(b, int64(t.Year()), 10)
  337. } else {
  338. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  339. }
  340. return string(b)
  341. }
  342. // FmtDateLong returns the long date representation of 't' for 'km_KH'
  343. func (km *km_KH) FmtDateLong(t time.Time) string {
  344. b := make([]byte, 0, 32)
  345. b = strconv.AppendInt(b, int64(t.Day()), 10)
  346. b = append(b, []byte{0x20}...)
  347. b = append(b, km.monthsWide[t.Month()]...)
  348. b = append(b, []byte{0x20}...)
  349. if t.Year() > 0 {
  350. b = strconv.AppendInt(b, int64(t.Year()), 10)
  351. } else {
  352. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  353. }
  354. return string(b)
  355. }
  356. // FmtDateFull returns the full date representation of 't' for 'km_KH'
  357. func (km *km_KH) FmtDateFull(t time.Time) string {
  358. b := make([]byte, 0, 32)
  359. b = append(b, km.daysWide[t.Weekday()]...)
  360. b = append(b, []byte{0x20}...)
  361. b = strconv.AppendInt(b, int64(t.Day()), 10)
  362. b = append(b, []byte{0x20}...)
  363. b = append(b, km.monthsWide[t.Month()]...)
  364. b = append(b, []byte{0x20}...)
  365. if t.Year() > 0 {
  366. b = strconv.AppendInt(b, int64(t.Year()), 10)
  367. } else {
  368. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  369. }
  370. return string(b)
  371. }
  372. // FmtTimeShort returns the short time representation of 't' for 'km_KH'
  373. func (km *km_KH) FmtTimeShort(t time.Time) string {
  374. b := make([]byte, 0, 32)
  375. h := t.Hour()
  376. if h > 12 {
  377. h -= 12
  378. }
  379. b = strconv.AppendInt(b, int64(h), 10)
  380. b = append(b, km.timeSeparator...)
  381. if t.Minute() < 10 {
  382. b = append(b, '0')
  383. }
  384. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  385. b = append(b, []byte{0x20}...)
  386. if t.Hour() < 12 {
  387. b = append(b, km.periodsAbbreviated[0]...)
  388. } else {
  389. b = append(b, km.periodsAbbreviated[1]...)
  390. }
  391. return string(b)
  392. }
  393. // FmtTimeMedium returns the medium time representation of 't' for 'km_KH'
  394. func (km *km_KH) FmtTimeMedium(t time.Time) string {
  395. b := make([]byte, 0, 32)
  396. h := t.Hour()
  397. if h > 12 {
  398. h -= 12
  399. }
  400. b = strconv.AppendInt(b, int64(h), 10)
  401. b = append(b, km.timeSeparator...)
  402. if t.Minute() < 10 {
  403. b = append(b, '0')
  404. }
  405. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  406. b = append(b, km.timeSeparator...)
  407. if t.Second() < 10 {
  408. b = append(b, '0')
  409. }
  410. b = strconv.AppendInt(b, int64(t.Second()), 10)
  411. b = append(b, []byte{0x20}...)
  412. if t.Hour() < 12 {
  413. b = append(b, km.periodsAbbreviated[0]...)
  414. } else {
  415. b = append(b, km.periodsAbbreviated[1]...)
  416. }
  417. return string(b)
  418. }
  419. // FmtTimeLong returns the long time representation of 't' for 'km_KH'
  420. func (km *km_KH) FmtTimeLong(t time.Time) string {
  421. b := make([]byte, 0, 32)
  422. h := t.Hour()
  423. if h > 12 {
  424. h -= 12
  425. }
  426. b = strconv.AppendInt(b, int64(h), 10)
  427. b = append(b, km.timeSeparator...)
  428. if t.Minute() < 10 {
  429. b = append(b, '0')
  430. }
  431. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  432. b = append(b, km.timeSeparator...)
  433. if t.Second() < 10 {
  434. b = append(b, '0')
  435. }
  436. b = strconv.AppendInt(b, int64(t.Second()), 10)
  437. b = append(b, []byte{0x20}...)
  438. if t.Hour() < 12 {
  439. b = append(b, km.periodsAbbreviated[0]...)
  440. } else {
  441. b = append(b, km.periodsAbbreviated[1]...)
  442. }
  443. b = append(b, []byte{0x20}...)
  444. tz, _ := t.Zone()
  445. b = append(b, tz...)
  446. return string(b)
  447. }
  448. // FmtTimeFull returns the full time representation of 't' for 'km_KH'
  449. func (km *km_KH) FmtTimeFull(t time.Time) string {
  450. b := make([]byte, 0, 32)
  451. h := t.Hour()
  452. if h > 12 {
  453. h -= 12
  454. }
  455. b = strconv.AppendInt(b, int64(h), 10)
  456. b = append(b, km.timeSeparator...)
  457. if t.Minute() < 10 {
  458. b = append(b, '0')
  459. }
  460. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  461. b = append(b, km.timeSeparator...)
  462. if t.Second() < 10 {
  463. b = append(b, '0')
  464. }
  465. b = strconv.AppendInt(b, int64(t.Second()), 10)
  466. b = append(b, []byte{0x20}...)
  467. if t.Hour() < 12 {
  468. b = append(b, km.periodsAbbreviated[0]...)
  469. } else {
  470. b = append(b, km.periodsAbbreviated[1]...)
  471. }
  472. b = append(b, []byte{0x20}...)
  473. tz, _ := t.Zone()
  474. if btz, ok := km.timezones[tz]; ok {
  475. b = append(b, btz...)
  476. } else {
  477. b = append(b, tz...)
  478. }
  479. return string(b)
  480. }