...

Source file src/github.com/go-playground/locales/km_KH/km_KH.go

Documentation: github.com/go-playground/locales/km_KH

     1  package km_KH
     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 km_KH 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  	currencyNegativePrefix string
    26  	currencyNegativeSuffix 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 'km_KH' locale
    45  func New() locales.Translator {
    46  	return &km_KH{
    47  		locale:                 "km_KH",
    48  		pluralsCardinal:        []locales.PluralRule{6},
    49  		pluralsOrdinal:         []locales.PluralRule{6},
    50  		pluralsRange:           []locales.PluralRule{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", "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", "MRU", "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", "UYW", "UZS", "VEB", "VEF", "VES", "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"},
    59  		currencyNegativePrefix: "(",
    60  		currencyNegativeSuffix: ")",
    61  		monthsAbbreviated:      []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"},
    62  		monthsNarrow:           []string{"", "ម", "ក", "ម", "ម", "ឧ", "ម", "ក", "ស", "ក", "ត", "វ", "ធ"},
    63  		monthsWide:             []string{"", "មករា", "កុម្ភៈ", "មីនា", "មេសា", "ឧសភា", "មិថុនា", "កក្កដា", "សីហា", "កញ្ញា", "តុលា", "វិច្ឆិកា", "ធ្នូ"},
    64  		daysAbbreviated:        []string{"អាទិត្យ", "ចន្ទ", "អង្គារ", "ពុធ", "ព្រហ", "សុក្រ", "សៅរ៍"},
    65  		daysNarrow:             []string{"អ", "ច", "អ", "ព", "ព", "ស", "ស"},
    66  		daysShort:              []string{"អា", "ច", "អ", "ពុ", "ព្រ", "សុ", "ស"},
    67  		daysWide:               []string{"អាទិត្យ", "ច័ន្ទ", "អង្គារ", "ពុធ", "ព្រហស្បតិ៍", "សុក្រ", "សៅរ៍"},
    68  		periodsAbbreviated:     []string{"AM", "PM"},
    69  		periodsNarrow:          []string{"a", "p"},
    70  		periodsWide:            []string{"AM", "PM"},
    71  		erasAbbreviated:        []string{"មុន គ.ស.", "គ.ស."},
    72  		erasNarrow:             []string{"", ""},
    73  		erasWide:               []string{"មុន\u200bគ្រិស្តសករាជ", "គ្រិស្តសករាជ"},
    74  		timezones:              map[string]string{"ACDT": "ម៉ោង\u200bពេលថ្ងៃ\u200b\u200b\u200b\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "ACST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "ACWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "ACWST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bភាគ\u200bខាង\u200bលិច\u200bនៃ\u200bអូស្ត្រាលី\u200bកណ្ដាល", "ADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអាត្លង់ទិក", "AEDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "AEST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bកើត", "AKDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200b\u200bអាឡាស្កា", "AKST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាឡាស្កា", "ARST": "ម៉ោង\u200bនៅ\u200bអាហ្សង់ទីននារដូវក្តៅ", "ART": "ម៉ោងស្តង់ដារ\u200bនៅ\u200bអាហ្សង់ទីន", "AST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាត្លង់ទិក", "AWDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "AWST": "ម៉ោង\u200b\u200bស្តង់ដារ\u200bនៅ\u200bអូស្ត្រាលី\u200bខាង\u200bលិច", "BOT": "ម៉ោង\u200bនៅ\u200bបូលីវី", "BT": "ម៉ោងនៅប៊ូតង់", "CAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bកណ្ដាល", "CDT": "ម៉ោង\u200b\u200bពេលថ្ងៃនៅ\u200bទ្វីបអាមេរិក\u200bខាង\u200bជើងភាគកណ្តាល", "CHADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bចាថាំ", "CHAST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bចាថាំ", "CLST": "ម៉ោងនៅស៊ីលីនារដូវក្តៅ", "CLT": "ម៉ោងស្តង់ដារនៅស៊ីលី", "COST": "ម៉ោង\u200bនៅ\u200bកូឡុំប៊ីនា\u200bរដូវ\u200bក្ដៅ", "COT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bកូឡុំប៊ី", "CST": "ម៉ោង\u200b\u200bស្តង់ដារនៅ\u200bទ្វីបអាមេរិក\u200bខាង\u200bជើងភាគកណ្តាល", "ChST": "ម៉ោង\u200bស្តង់ដារនៅ\u200bចាំម៉ូរ៉ូ", "EAT": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bកើត", "ECT": "ម៉ោង\u200bនៅ\u200bអេក្វាទ័រ", "EDT": "ម៉ោងពេលថ្ងៃនៅទ្វីបអាមេរិកខាងជើងភាគខាងកើត", "EST": "ម៉ោងស្តង់ដារនៅទ្វីបអាមេរិកខាងជើងភាគខាងកើត", "GFT": "ម៉ោង\u200bនៅ\u200bហ្គីយ៉ាន\u200bបារាំង", "GMT": "ម៉ោងនៅគ្រីនវិច", "GST": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bកាល់", "GYT": "ម៉ោង\u200bនៅ\u200bហ្គីយ៉ាន", "HADT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "HAST": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bហាវៃ-អាល់ដ្យូសិន", "HAT": "ម៉ោង\u200bពេលថ្ងៃ\u200bនៅ\u200bញូវហ្វោនឡែន", "HECU": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bគុយបា", "HEEG": "ម៉ោង\u200bនៅ\u200bហ្គ្រីនលែនខាង\u200bកើតនា\u200bរដូវ\u200bក្ដៅ", "HENOMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "HEOG": "ម៉ោងនៅហ្គ្រីនលែនខាងលិចនារដូវក្តៅ", "HEPM": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "HEPMX": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bប៉ាស៊ីហ្វិក\u200bម៉ិកស៊ិក", "HKST": "ម៉ោងនៅ\u200bហុងកុងនា\u200bរដូវ\u200bក្ដៅ\u200b", "HKT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bហុងកុង", "HNCU": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bគុយបា", "HNEG": "ម៉ោង\u200b\u200b\u200bស្តង់ដារ\u200bនៅ\u200b\u200bហ្គ្រីនលែន\u200bខាង\u200bកើត", "HNNOMX": "ម៉ោង\u200bស្តង់ដារនៅ\u200bម៉ិកស៊ិកភាគពាយព្យ", "HNOG": "ម៉ោងស្តង់ដារនៅហ្គ្រីនលែនខាងលិច", "HNPM": "ម៉ោង\u200bស្តង់ដារ\u200bនៅសង់\u200bព្យែរ និង\u200bមីគុយឡុង", "HNPMX": "ម៉ោង\u200bស្តង់ដា\u200bនៅ\u200bប៉ាស៊ីហ្វិក\u200bម៉ិកស៊ិក", "HNT": "ម៉ោង\u200b\u200bស្តង់ដារ\u200b\u200bនៅ\u200bញូវហ្វោនឡែន", "IST": "ម៉ោង\u200bស្តង់ដារនៅ\u200bឥណ្ឌា", "JDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅជប៉ុន", "JST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bជប៉ុន", "LHDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bឡតហៅ", "LHST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bឡត\u200bហៅ", "MDT": "ម៉ោង\u200bពេលថ្ងៃនៅតំបន់ភ្នំនៃទ្វីប\u200bអាមេរិក\u200b\u200b\u200bខាង\u200bជើង", "MESZ": "ម៉ោង\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាលនា\u200bរដូវ\u200bក្ដៅ", "MEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bកណ្ដាល", "MST": "ម៉ោងស្តង់ដារ\u200bនៅតំបន់ភ្នំនៃទ្វីប\u200bអាមេរិក\u200b\u200b\u200bខាង\u200bជើង", "MYT": "ម៉ោង\u200bនៅ\u200bម៉ាឡេស៊ី", "NZDT": "ម៉ោង\u200bពេល\u200bថ្ងៃ\u200bនៅ\u200bនូវែលសេឡង់", "NZST": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bនូវែលសេឡង់", "OESZ": "ម៉ោង\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200bនា\u200bរដូវ\u200bក្ដៅ", "OEZ": "ម៉ោង\u200bស្តង់ដារ\u200b\u200bនៅ\u200bអឺរ៉ុប\u200b\u200bខាង\u200bកើត\u200b", "PDT": "ម៉ោង\u200b\u200bពេលថ្ងៃនៅទ្វីប\u200bអាមរិក\u200bខាង\u200bជើងភាគខាងលិច", "PST": "ម៉ោងស្តង់ដារ\u200b\u200b\u200bនៅទ្វីប\u200bអាមរិក\u200bខាង\u200bជើងភាគខាងលិច", "SAST": "ម៉ោង\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bត្បូង", "SGT": "ម៉ោង\u200bនៅ\u200bសិង្ហបូរី", "SRT": "ម៉ោង\u200bនៅ\u200bសូរីណាម", "TMST": "ម៉ោង\u200bរដូវ\u200bក្ដៅ\u200bនៅ\u200bតួកម៉េនីស្ថាន\u200b", "TMT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅតួកម៉េនីស្ថាន", "UYST": "ម៉ោង\u200bនៅ\u200bអ៊ុយរូហ្គាយនា\u200b\u200bរដូវ\u200bក្ដៅ", "UYT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអ៊ុយរូហ្គាយ", "VET": "ម៉ោង\u200bនៅ\u200bវ៉េណេស៊ុយអេឡា", "WARST": "ម៉ោង\u200bនៅ\u200bអាហ្សង់ទីនភាគខាងលិចនារដូវក្តៅ", "WART": "ម៉ោងស្តង់ដារ\u200bនៅ\u200bអាហ្សង់ទីនភាគខាងលិច", "WAST": "ម៉ោងនៅ\u200bអាហ្វ្រិក\u200b\u200b\u200bខាងលិច\u200b\u200bនារដូវ\u200bក្ដៅ\u200b", "WAT": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអាហ្វ្រិក\u200bខាង\u200bលិច", "WESZ": "ម៉ោង\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិចនារដូវ\u200bក្ដៅ\u200b", "WEZ": "ម៉ោង\u200bស្តង់ដារ\u200bនៅ\u200bអឺរ៉ុប\u200bខាង\u200bលិច", "WIB": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bលិច", "WIT": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200bខាង\u200bកើត", "WITA": "ម៉ោង\u200bនៅ\u200bឥណ្ឌូណេស៊ី\u200b\u200b\u200bកណ្ដាល", "∅∅∅": "ម៉ោង\u200bនៅ\u200bប្រាស៊ីលីយ៉ានា\u200b\u200bរដូវ\u200bក្ដៅ"},
    75  	}
    76  }
    77  
    78  // Locale returns the current translators string locale
    79  func (km *km_KH) Locale() string {
    80  	return km.locale
    81  }
    82  
    83  // PluralsCardinal returns the list of cardinal plural rules associated with 'km_KH'
    84  func (km *km_KH) PluralsCardinal() []locales.PluralRule {
    85  	return km.pluralsCardinal
    86  }
    87  
    88  // PluralsOrdinal returns the list of ordinal plural rules associated with 'km_KH'
    89  func (km *km_KH) PluralsOrdinal() []locales.PluralRule {
    90  	return km.pluralsOrdinal
    91  }
    92  
    93  // PluralsRange returns the list of range plural rules associated with 'km_KH'
    94  func (km *km_KH) PluralsRange() []locales.PluralRule {
    95  	return km.pluralsRange
    96  }
    97  
    98  // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'km_KH'
    99  func (km *km_KH) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
   100  	return locales.PluralRuleOther
   101  }
   102  
   103  // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'km_KH'
   104  func (km *km_KH) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
   105  	return locales.PluralRuleOther
   106  }
   107  
   108  // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'km_KH'
   109  func (km *km_KH) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
   110  	return locales.PluralRuleOther
   111  }
   112  
   113  // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
   114  func (km *km_KH) MonthAbbreviated(month time.Month) string {
   115  	return km.monthsAbbreviated[month]
   116  }
   117  
   118  // MonthsAbbreviated returns the locales abbreviated months
   119  func (km *km_KH) MonthsAbbreviated() []string {
   120  	return km.monthsAbbreviated[1:]
   121  }
   122  
   123  // MonthNarrow returns the locales narrow month given the 'month' provided
   124  func (km *km_KH) MonthNarrow(month time.Month) string {
   125  	return km.monthsNarrow[month]
   126  }
   127  
   128  // MonthsNarrow returns the locales narrow months
   129  func (km *km_KH) MonthsNarrow() []string {
   130  	return km.monthsNarrow[1:]
   131  }
   132  
   133  // MonthWide returns the locales wide month given the 'month' provided
   134  func (km *km_KH) MonthWide(month time.Month) string {
   135  	return km.monthsWide[month]
   136  }
   137  
   138  // MonthsWide returns the locales wide months
   139  func (km *km_KH) MonthsWide() []string {
   140  	return km.monthsWide[1:]
   141  }
   142  
   143  // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
   144  func (km *km_KH) WeekdayAbbreviated(weekday time.Weekday) string {
   145  	return km.daysAbbreviated[weekday]
   146  }
   147  
   148  // WeekdaysAbbreviated returns the locales abbreviated weekdays
   149  func (km *km_KH) WeekdaysAbbreviated() []string {
   150  	return km.daysAbbreviated
   151  }
   152  
   153  // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
   154  func (km *km_KH) WeekdayNarrow(weekday time.Weekday) string {
   155  	return km.daysNarrow[weekday]
   156  }
   157  
   158  // WeekdaysNarrow returns the locales narrow weekdays
   159  func (km *km_KH) WeekdaysNarrow() []string {
   160  	return km.daysNarrow
   161  }
   162  
   163  // WeekdayShort returns the locales short weekday given the 'weekday' provided
   164  func (km *km_KH) WeekdayShort(weekday time.Weekday) string {
   165  	return km.daysShort[weekday]
   166  }
   167  
   168  // WeekdaysShort returns the locales short weekdays
   169  func (km *km_KH) WeekdaysShort() []string {
   170  	return km.daysShort
   171  }
   172  
   173  // WeekdayWide returns the locales wide weekday given the 'weekday' provided
   174  func (km *km_KH) WeekdayWide(weekday time.Weekday) string {
   175  	return km.daysWide[weekday]
   176  }
   177  
   178  // WeekdaysWide returns the locales wide weekdays
   179  func (km *km_KH) WeekdaysWide() []string {
   180  	return km.daysWide
   181  }
   182  
   183  // Decimal returns the decimal point of number
   184  func (km *km_KH) Decimal() string {
   185  	return km.decimal
   186  }
   187  
   188  // Group returns the group of number
   189  func (km *km_KH) Group() string {
   190  	return km.group
   191  }
   192  
   193  // Group returns the minus sign of number
   194  func (km *km_KH) Minus() string {
   195  	return km.minus
   196  }
   197  
   198  // FmtNumber returns 'num' with digits/precision of 'v' for 'km_KH' and handles both Whole and Real numbers based on 'v'
   199  func (km *km_KH) FmtNumber(num float64, v uint64) string {
   200  
   201  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   202  	l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   203  	count := 0
   204  	inWhole := v == 0
   205  	b := make([]byte, 0, l)
   206  
   207  	for i := len(s) - 1; i >= 0; i-- {
   208  
   209  		if s[i] == '.' {
   210  			b = append(b, km.decimal[0])
   211  			inWhole = true
   212  			continue
   213  		}
   214  
   215  		if inWhole {
   216  			if count == 3 {
   217  				b = append(b, km.group[0])
   218  				count = 1
   219  			} else {
   220  				count++
   221  			}
   222  		}
   223  
   224  		b = append(b, s[i])
   225  	}
   226  
   227  	if num < 0 {
   228  		b = append(b, km.minus[0])
   229  	}
   230  
   231  	// reverse
   232  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   233  		b[i], b[j] = b[j], b[i]
   234  	}
   235  
   236  	return string(b)
   237  }
   238  
   239  // FmtPercent returns 'num' with digits/precision of 'v' for 'km_KH' and handles both Whole and Real numbers based on 'v'
   240  // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
   241  func (km *km_KH) FmtPercent(num float64, v uint64) string {
   242  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   243  	l := len(s) + 3
   244  	b := make([]byte, 0, l)
   245  
   246  	for i := len(s) - 1; i >= 0; i-- {
   247  
   248  		if s[i] == '.' {
   249  			b = append(b, km.decimal[0])
   250  			continue
   251  		}
   252  
   253  		b = append(b, s[i])
   254  	}
   255  
   256  	if num < 0 {
   257  		b = append(b, km.minus[0])
   258  	}
   259  
   260  	// reverse
   261  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   262  		b[i], b[j] = b[j], b[i]
   263  	}
   264  
   265  	b = append(b, km.percent...)
   266  
   267  	return string(b)
   268  }
   269  
   270  // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'km_KH'
   271  func (km *km_KH) FmtCurrency(num float64, v uint64, currency currency.Type) string {
   272  
   273  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   274  	symbol := km.currencies[currency]
   275  	l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
   276  	count := 0
   277  	inWhole := v == 0
   278  	b := make([]byte, 0, l)
   279  
   280  	for i := len(s) - 1; i >= 0; i-- {
   281  
   282  		if s[i] == '.' {
   283  			b = append(b, km.decimal[0])
   284  			inWhole = true
   285  			continue
   286  		}
   287  
   288  		if inWhole {
   289  			if count == 3 {
   290  				b = append(b, km.group[0])
   291  				count = 1
   292  			} else {
   293  				count++
   294  			}
   295  		}
   296  
   297  		b = append(b, s[i])
   298  	}
   299  
   300  	if num < 0 {
   301  		b = append(b, km.minus[0])
   302  	}
   303  
   304  	// reverse
   305  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   306  		b[i], b[j] = b[j], b[i]
   307  	}
   308  
   309  	if int(v) < 2 {
   310  
   311  		if v == 0 {
   312  			b = append(b, km.decimal...)
   313  		}
   314  
   315  		for i := 0; i < 2-int(v); i++ {
   316  			b = append(b, '0')
   317  		}
   318  	}
   319  
   320  	b = append(b, symbol...)
   321  
   322  	return string(b)
   323  }
   324  
   325  // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'km_KH'
   326  // in accounting notation.
   327  func (km *km_KH) FmtAccounting(num float64, v uint64, currency currency.Type) string {
   328  
   329  	s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
   330  	symbol := km.currencies[currency]
   331  	l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
   332  	count := 0
   333  	inWhole := v == 0
   334  	b := make([]byte, 0, l)
   335  
   336  	for i := len(s) - 1; i >= 0; i-- {
   337  
   338  		if s[i] == '.' {
   339  			b = append(b, km.decimal[0])
   340  			inWhole = true
   341  			continue
   342  		}
   343  
   344  		if inWhole {
   345  			if count == 3 {
   346  				b = append(b, km.group[0])
   347  				count = 1
   348  			} else {
   349  				count++
   350  			}
   351  		}
   352  
   353  		b = append(b, s[i])
   354  	}
   355  
   356  	if num < 0 {
   357  
   358  		b = append(b, km.currencyNegativePrefix[0])
   359  
   360  	}
   361  
   362  	// reverse
   363  	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
   364  		b[i], b[j] = b[j], b[i]
   365  	}
   366  
   367  	if int(v) < 2 {
   368  
   369  		if v == 0 {
   370  			b = append(b, km.decimal...)
   371  		}
   372  
   373  		for i := 0; i < 2-int(v); i++ {
   374  			b = append(b, '0')
   375  		}
   376  	}
   377  
   378  	if num < 0 {
   379  		b = append(b, km.currencyNegativeSuffix...)
   380  		b = append(b, symbol...)
   381  	} else {
   382  
   383  		b = append(b, symbol...)
   384  	}
   385  
   386  	return string(b)
   387  }
   388  
   389  // FmtDateShort returns the short date representation of 't' for 'km_KH'
   390  func (km *km_KH) FmtDateShort(t time.Time) string {
   391  
   392  	b := make([]byte, 0, 32)
   393  
   394  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   395  	b = append(b, []byte{0x2f}...)
   396  	b = strconv.AppendInt(b, int64(t.Month()), 10)
   397  	b = append(b, []byte{0x2f}...)
   398  
   399  	if t.Year() > 9 {
   400  		b = append(b, strconv.Itoa(t.Year())[2:]...)
   401  	} else {
   402  		b = append(b, strconv.Itoa(t.Year())[1:]...)
   403  	}
   404  
   405  	return string(b)
   406  }
   407  
   408  // FmtDateMedium returns the medium date representation of 't' for 'km_KH'
   409  func (km *km_KH) FmtDateMedium(t time.Time) string {
   410  
   411  	b := make([]byte, 0, 32)
   412  
   413  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   414  	b = append(b, []byte{0x20}...)
   415  	b = append(b, km.monthsAbbreviated[t.Month()]...)
   416  	b = append(b, []byte{0x20}...)
   417  
   418  	if t.Year() > 0 {
   419  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   420  	} else {
   421  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   422  	}
   423  
   424  	return string(b)
   425  }
   426  
   427  // FmtDateLong returns the long date representation of 't' for 'km_KH'
   428  func (km *km_KH) FmtDateLong(t time.Time) string {
   429  
   430  	b := make([]byte, 0, 32)
   431  
   432  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   433  	b = append(b, []byte{0x20}...)
   434  	b = append(b, km.monthsWide[t.Month()]...)
   435  	b = append(b, []byte{0x20}...)
   436  
   437  	if t.Year() > 0 {
   438  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   439  	} else {
   440  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   441  	}
   442  
   443  	return string(b)
   444  }
   445  
   446  // FmtDateFull returns the full date representation of 't' for 'km_KH'
   447  func (km *km_KH) FmtDateFull(t time.Time) string {
   448  
   449  	b := make([]byte, 0, 32)
   450  
   451  	b = append(b, km.daysWide[t.Weekday()]...)
   452  	b = append(b, []byte{0x20}...)
   453  	b = strconv.AppendInt(b, int64(t.Day()), 10)
   454  	b = append(b, []byte{0x20}...)
   455  	b = append(b, km.monthsWide[t.Month()]...)
   456  	b = append(b, []byte{0x20}...)
   457  
   458  	if t.Year() > 0 {
   459  		b = strconv.AppendInt(b, int64(t.Year()), 10)
   460  	} else {
   461  		b = strconv.AppendInt(b, int64(-t.Year()), 10)
   462  	}
   463  
   464  	return string(b)
   465  }
   466  
   467  // FmtTimeShort returns the short time representation of 't' for 'km_KH'
   468  func (km *km_KH) FmtTimeShort(t time.Time) string {
   469  
   470  	b := make([]byte, 0, 32)
   471  
   472  	h := t.Hour()
   473  
   474  	if h > 12 {
   475  		h -= 12
   476  	}
   477  
   478  	b = strconv.AppendInt(b, int64(h), 10)
   479  	b = append(b, km.timeSeparator...)
   480  
   481  	if t.Minute() < 10 {
   482  		b = append(b, '0')
   483  	}
   484  
   485  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   486  	b = append(b, []byte{0x20}...)
   487  
   488  	if t.Hour() < 12 {
   489  		b = append(b, km.periodsAbbreviated[0]...)
   490  	} else {
   491  		b = append(b, km.periodsAbbreviated[1]...)
   492  	}
   493  
   494  	return string(b)
   495  }
   496  
   497  // FmtTimeMedium returns the medium time representation of 't' for 'km_KH'
   498  func (km *km_KH) FmtTimeMedium(t time.Time) string {
   499  
   500  	b := make([]byte, 0, 32)
   501  
   502  	h := t.Hour()
   503  
   504  	if h > 12 {
   505  		h -= 12
   506  	}
   507  
   508  	b = strconv.AppendInt(b, int64(h), 10)
   509  	b = append(b, km.timeSeparator...)
   510  
   511  	if t.Minute() < 10 {
   512  		b = append(b, '0')
   513  	}
   514  
   515  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   516  	b = append(b, km.timeSeparator...)
   517  
   518  	if t.Second() < 10 {
   519  		b = append(b, '0')
   520  	}
   521  
   522  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   523  	b = append(b, []byte{0x20}...)
   524  
   525  	if t.Hour() < 12 {
   526  		b = append(b, km.periodsAbbreviated[0]...)
   527  	} else {
   528  		b = append(b, km.periodsAbbreviated[1]...)
   529  	}
   530  
   531  	return string(b)
   532  }
   533  
   534  // FmtTimeLong returns the long time representation of 't' for 'km_KH'
   535  func (km *km_KH) FmtTimeLong(t time.Time) string {
   536  
   537  	b := make([]byte, 0, 32)
   538  
   539  	h := t.Hour()
   540  
   541  	if h > 12 {
   542  		h -= 12
   543  	}
   544  
   545  	b = strconv.AppendInt(b, int64(h), 10)
   546  	b = append(b, km.timeSeparator...)
   547  
   548  	if t.Minute() < 10 {
   549  		b = append(b, '0')
   550  	}
   551  
   552  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   553  	b = append(b, km.timeSeparator...)
   554  
   555  	if t.Second() < 10 {
   556  		b = append(b, '0')
   557  	}
   558  
   559  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   560  	b = append(b, []byte{0x20}...)
   561  
   562  	if t.Hour() < 12 {
   563  		b = append(b, km.periodsAbbreviated[0]...)
   564  	} else {
   565  		b = append(b, km.periodsAbbreviated[1]...)
   566  	}
   567  
   568  	b = append(b, []byte{0x20}...)
   569  
   570  	tz, _ := t.Zone()
   571  	b = append(b, tz...)
   572  
   573  	return string(b)
   574  }
   575  
   576  // FmtTimeFull returns the full time representation of 't' for 'km_KH'
   577  func (km *km_KH) FmtTimeFull(t time.Time) string {
   578  
   579  	b := make([]byte, 0, 32)
   580  
   581  	h := t.Hour()
   582  
   583  	if h > 12 {
   584  		h -= 12
   585  	}
   586  
   587  	b = strconv.AppendInt(b, int64(h), 10)
   588  	b = append(b, km.timeSeparator...)
   589  
   590  	if t.Minute() < 10 {
   591  		b = append(b, '0')
   592  	}
   593  
   594  	b = strconv.AppendInt(b, int64(t.Minute()), 10)
   595  	b = append(b, km.timeSeparator...)
   596  
   597  	if t.Second() < 10 {
   598  		b = append(b, '0')
   599  	}
   600  
   601  	b = strconv.AppendInt(b, int64(t.Second()), 10)
   602  	b = append(b, []byte{0x20}...)
   603  
   604  	if t.Hour() < 12 {
   605  		b = append(b, km.periodsAbbreviated[0]...)
   606  	} else {
   607  		b = append(b, km.periodsAbbreviated[1]...)
   608  	}
   609  
   610  	b = append(b, []byte{0x20}...)
   611  
   612  	tz, _ := t.Zone()
   613  
   614  	if btz, ok := km.timezones[tz]; ok {
   615  		b = append(b, btz...)
   616  	} else {
   617  		b = append(b, tz...)
   618  	}
   619  
   620  	return string(b)
   621  }
   622  

View as plain text