pa_Guru.go 24 KB

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