or_IN.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. package or_IN
  2. import (
  3. "math"
  4. "strconv"
  5. "time"
  6. "github.com/go-playground/locales"
  7. "github.com/go-playground/locales/currency"
  8. )
  9. type or_IN 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 'or_IN' locale
  41. func New() locales.Translator {
  42. return &or_IN{
  43. locale: "or_IN",
  44. pluralsCardinal: []locales.PluralRule{2, 6},
  45. pluralsOrdinal: []locales.PluralRule{2, 3, 4, 5, 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{"ପୂ", "ଅ"},
  66. periodsWide: []string{"AM", "PM"},
  67. erasAbbreviated: []string{"BC", "AD"},
  68. erasNarrow: []string{"", ""},
  69. erasWide: []string{"ଖ୍ରୀଷ୍ଟପୂର୍ବ", "ଖ୍ରୀଷ୍ଟାବ୍ଦ"},
  70. timezones: map[string]string{"JDT": "ଜାପାନ ଦିବାଲୋକ ସମୟ", "ACDT": "ଅଷ୍ଟ୍ରେଲିୟ ମଧ୍ୟ ଦିବାଲୋକ ସମୟ", "VET": "ଭେନିଜୁଏଲା ସମୟ", "PST": "ପାସିଫିକ୍ ମାନାଙ୍କ ସମୟ", "HEEG": "ପୂର୍ବ ଗ୍ରୀନଲ୍ୟାଣ୍ଡ୍ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "ChST": "ଚାମୋରୋ ମାନାଙ୍କ ସମୟ", "WEZ": "ପଶ୍ଚିମାଞ୍ଚଳ ୟୁରୋପୀୟ ମାନାଙ୍କ ସମୟ", "GYT": "ଗୁଏନା ସମୟ", "AEDT": "ଅଷ୍ଟ୍ରେଲିୟ ପୂର୍ବ ଦିବାଲୋକ ସମୟ", "SGT": "ସିଙ୍ଗାପୁର୍\u200c ମାନାଙ୍କ ସମୟ", "HKT": "ହଂ କଂ ମାନାଙ୍କ ସମୟ", "COST": "କଲମ୍ବିଆ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "SAST": "ଦକ୍ଷିଣ ଆଫ୍ରିକା ମାନାଙ୍କ ସମୟ", "ECT": "ଇକ୍ୱେଡର ସମୟ", "LHDT": "ଲର୍ଡ ହୋୱେ ଦିବାଲୋକ ସମୟ", "ADT": "ଆଟଲାଣ୍ଟିକ୍ ଦିବାଲୋକ ସମୟ", "WITA": "ମଧ୍ୟ ଇଣ୍ଡୋନେସିଆ ସମୟ", "UYST": "ଉରୁଗୁଏ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "WESZ": "ପଶ୍ଚିମାଞ୍ଚଳ ୟୁରୋପୀୟ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "JST": "ଜାପାନ ମାନାଙ୍କ ସମୟ", "WARST": "ପଶ୍ଚିମ ଆର୍ଜେଣ୍ଟିନା ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "HNT": "ନ୍ୟୁଫାଉଣ୍ଡଲ୍ୟାଣ୍ଡ୍ ମାନାଙ୍କ ସମୟ", "HEPM": "ସେଣ୍ଟ. ପିଏରେ ଏବଂ ମିକ୍ୟୁଲୋନ୍ ଦିବାଲୋକ ସମୟ", "MYT": "ମାଲେସିଆ ସମୟ", "ACWDT": "ଅଷ୍ଟ୍ରେଲିୟ ମଧ୍ୟ ପଶ୍ଚିମ ଦିବାଲୋକ ସମୟ", "HNEG": "ପୂର୍ବ ଗ୍ରୀନଲ୍ୟାଣ୍ଡ୍ ମାନାଙ୍କ ସମୟ", "HENOMX": "ଉତ୍ତରପଶ୍ଚିମ ମେକ୍ସିକୋ ଦିବାଲୋକ ସମୟ", "AWST": "ଅଷ୍ଟ୍ରେଲିୟ ପଶ୍ଚିମ ମାନାଙ୍କ ସମୟ", "AWDT": "ଅଷ୍ଟ୍ରେଲିୟ ପଶ୍ଚିମ ଦିବାଲୋକ ସମୟ", "HEPMX": "ମେକ୍ସିକୋ ପାସିଫିକ୍ ଦିବାଲୋକ ସମୟ", "NZDT": "ନ୍ୟୁଜିଲାଣ୍ଡ ଦିବାଲୋକ ସମୟ", "HAT": "ନ୍ୟୁଫାଉଣ୍ଡଲ୍ୟାଣ୍ଡ୍ ଦିବାଲୋକ ସମୟ", "WIT": "ପୂର୍ବ ଇଣ୍ଡୋନେସିଆ ସମୟ", "HECU": "କ୍ୟୁବା ଦିବାଲୋକ ସମୟ", "EAT": "ପୂର୍ବ ଆଫ୍ରିକା ସମୟ", "HNCU": "କ୍ୟୁବା ମାନାଙ୍କ ସମୟ", "HNPMX": "ମେକ୍ସିକୋ ପାସିଫିକ୍ ମାନାଙ୍କ ସମୟ", "∅∅∅": "ଆଜୋରେସ୍ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "IST": "ଭାରତ ମାନାଙ୍କ ସମୟ", "HNPM": "ସେଣ୍ଟ. ପିଏରେ ଏବଂ ମିକ୍ୟୁଲୋନ୍ ମାନାଙ୍କ ସମୟ", "HKST": "ହଂ କଂ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "CAT": "ମଧ୍ୟ ଆଫ୍ରିକା ସମୟ", "PDT": "ପାସିଫିକ୍ ଦିବାଲୋକ ସମୟ", "AEST": "ଅଷ୍ଟ୍ରେଲିୟ ପୂର୍ବ ମାନାଙ୍କ ସମୟ", "AKST": "ଆଲାସ୍କା ମାନାଙ୍କ ସମୟ", "EST": "ପୂର୍ବାଞ୍ଚଳ ମାନାଙ୍କ ସମୟ", "ACST": "ଅଷ୍ଟ୍ରେଲିୟ ମଧ୍ୟ ମାନାଙ୍କ ସମୟ", "GMT": "ଗ୍ରୀନୱିଚ୍ ମିନ୍ ସମୟ", "CST": "କେନ୍ଦ୍ରୀୟ ମାନାଙ୍କ ସମୟ", "CDT": "କେନ୍ଦ୍ରୀୟ ଦିବାଲୋକ ସମୟ", "TMST": "ତୁର୍କମେନିସ୍ତାନ ଖରାଦିନ ସମୟ", "COT": "କଲମ୍ବିଆ ମାନାଙ୍କ ସମୟ", "UYT": "ଉରୁଗୁଏ ମାନାଙ୍କ ସମୟ", "CHAST": "ଚାଥାମ୍\u200c ମାନାଙ୍କ ସମୟ", "BOT": "ବଲିଭିଆ ସମୟ", "AKDT": "ଆଲାସ୍କା ଦିବାଲୋକ ସମୟ", "HEOG": "ପଶ୍ଚିମ ଗ୍ରୀନଲ୍ୟାଣ୍ଡ୍ ଗ୍ରୀଷ୍ମ ସମୟ", "CLT": "ଚିଲି ମାନାଙ୍କ ସମୟ", "CLST": "ଚିଲି ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "HAST": "ହୱାଇ-ଆଲେଉଟିୟ ମାନାଙ୍କ ସମୟ", "WIB": "ପଶ୍ଚିମ ଇଣ୍ଡୋନେସିଆ ସମୟ", "BT": "ଭୁଟାନ ସମୟ", "NZST": "ନ୍ୟୁଜିଲାଣ୍ଡ ମାନାଙ୍କ ସମୟ", "EDT": "ପୂର୍ବାଞ୍ଚଳ ଦିବାଲୋକ ସମୟ", "ACWST": "ଅଷ୍ଟ୍ରେଲିୟ ମଧ୍ୟ ପଶ୍ଚିମ ମାନାଙ୍କ ସମୟ", "HNOG": "ପଶ୍ଚିମ ଗ୍ରୀନଲ୍ୟାଣ୍ଡ୍ ମାନାଙ୍କ ସମୟ", "MEZ": "କେନ୍ଦ୍ରୀୟ ୟୁରୋପୀୟ ମାନାଙ୍କ ସମୟ", "LHST": "ଲର୍ଡ ହୋୱେ ମାନାଙ୍କ ସମୟ", "TMT": "ତୁର୍କମେନିସ୍ତାନ ମାନାଙ୍କ ସମୟ", "ART": "ଆର୍ଜେଣ୍ଟିନା ମାନାଙ୍କ ସମୟ", "ARST": "ଆର୍ଜେଣ୍ଟିନା ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "AST": "ଆଟଲାଣ୍ଟିକ୍ ମାନାଙ୍କ ସମୟ", "WAT": "ପଶ୍ଚିମ ଆଫ୍ରିକା ମାନାଙ୍କ ସମୟ", "GFT": "ଫ୍ରେଞ୍ଚ ଗୁଆନା ସମୟ", "WART": "ପଶ୍ଚିମ ଆର୍ଜେଣ୍ଟିନା ମାନାଙ୍କ ସମୟ", "OEZ": "ପୂର୍ବାଞ୍ଚଳ ୟୁରୋପୀୟ ମାନାଙ୍କ ସମୟ", "OESZ": "ପୂର୍ବାଞ୍ଚଳ ୟୁରୋପୀୟ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "HADT": "ହୱାଇ-ଆଲେଉଟିୟ ଦିବାଲୋକ ସମୟ", "CHADT": "ଚାଥାମ୍\u200c ଦିବାଲୋକ ସମୟ", "MESZ": "କେନ୍ଦ୍ରୀୟ ୟୁରୋପୀୟ ଗ୍ରୀଷ୍ମକାଳ ସମୟ", "MST": "MST", "SRT": "ସୁରିନେମ୍\u200c ସମୟ", "HNNOMX": "ଉତ୍ତରପଶ୍ଚିମ ମେକ୍ସିକୋ ମାନାଙ୍କ ସମୟ", "MDT": "MDT", "WAST": "ପଶ୍ଚିମ ଆଫ୍ରିକା ଖରାଦିନ ସମୟ"},
  71. }
  72. }
  73. // Locale returns the current translators string locale
  74. func (or *or_IN) Locale() string {
  75. return or.locale
  76. }
  77. // PluralsCardinal returns the list of cardinal plural rules associated with 'or_IN'
  78. func (or *or_IN) PluralsCardinal() []locales.PluralRule {
  79. return or.pluralsCardinal
  80. }
  81. // PluralsOrdinal returns the list of ordinal plural rules associated with 'or_IN'
  82. func (or *or_IN) PluralsOrdinal() []locales.PluralRule {
  83. return or.pluralsOrdinal
  84. }
  85. // PluralsRange returns the list of range plural rules associated with 'or_IN'
  86. func (or *or_IN) PluralsRange() []locales.PluralRule {
  87. return or.pluralsRange
  88. }
  89. // CardinalPluralRule returns the cardinal PluralRule given 'num' and digits/precision of 'v' for 'or_IN'
  90. func (or *or_IN) CardinalPluralRule(num float64, v uint64) locales.PluralRule {
  91. n := math.Abs(num)
  92. if n == 1 {
  93. return locales.PluralRuleOne
  94. }
  95. return locales.PluralRuleOther
  96. }
  97. // OrdinalPluralRule returns the ordinal PluralRule given 'num' and digits/precision of 'v' for 'or_IN'
  98. func (or *or_IN) OrdinalPluralRule(num float64, v uint64) locales.PluralRule {
  99. n := math.Abs(num)
  100. if n == 1 || n == 5 || n >= 7 && n <= 9 {
  101. return locales.PluralRuleOne
  102. } else if n == 2 || n == 3 {
  103. return locales.PluralRuleTwo
  104. } else if n == 4 {
  105. return locales.PluralRuleFew
  106. } else if n == 6 {
  107. return locales.PluralRuleMany
  108. }
  109. return locales.PluralRuleOther
  110. }
  111. // RangePluralRule returns the ordinal PluralRule given 'num1', 'num2' and digits/precision of 'v1' and 'v2' for 'or_IN'
  112. func (or *or_IN) RangePluralRule(num1 float64, v1 uint64, num2 float64, v2 uint64) locales.PluralRule {
  113. return locales.PluralRuleOther
  114. }
  115. // MonthAbbreviated returns the locales abbreviated month given the 'month' provided
  116. func (or *or_IN) MonthAbbreviated(month time.Month) string {
  117. return or.monthsAbbreviated[month]
  118. }
  119. // MonthsAbbreviated returns the locales abbreviated months
  120. func (or *or_IN) MonthsAbbreviated() []string {
  121. return or.monthsAbbreviated[1:]
  122. }
  123. // MonthNarrow returns the locales narrow month given the 'month' provided
  124. func (or *or_IN) MonthNarrow(month time.Month) string {
  125. return or.monthsNarrow[month]
  126. }
  127. // MonthsNarrow returns the locales narrow months
  128. func (or *or_IN) MonthsNarrow() []string {
  129. return or.monthsNarrow[1:]
  130. }
  131. // MonthWide returns the locales wide month given the 'month' provided
  132. func (or *or_IN) MonthWide(month time.Month) string {
  133. return or.monthsWide[month]
  134. }
  135. // MonthsWide returns the locales wide months
  136. func (or *or_IN) MonthsWide() []string {
  137. return or.monthsWide[1:]
  138. }
  139. // WeekdayAbbreviated returns the locales abbreviated weekday given the 'weekday' provided
  140. func (or *or_IN) WeekdayAbbreviated(weekday time.Weekday) string {
  141. return or.daysAbbreviated[weekday]
  142. }
  143. // WeekdaysAbbreviated returns the locales abbreviated weekdays
  144. func (or *or_IN) WeekdaysAbbreviated() []string {
  145. return or.daysAbbreviated
  146. }
  147. // WeekdayNarrow returns the locales narrow weekday given the 'weekday' provided
  148. func (or *or_IN) WeekdayNarrow(weekday time.Weekday) string {
  149. return or.daysNarrow[weekday]
  150. }
  151. // WeekdaysNarrow returns the locales narrow weekdays
  152. func (or *or_IN) WeekdaysNarrow() []string {
  153. return or.daysNarrow
  154. }
  155. // WeekdayShort returns the locales short weekday given the 'weekday' provided
  156. func (or *or_IN) WeekdayShort(weekday time.Weekday) string {
  157. return or.daysShort[weekday]
  158. }
  159. // WeekdaysShort returns the locales short weekdays
  160. func (or *or_IN) WeekdaysShort() []string {
  161. return or.daysShort
  162. }
  163. // WeekdayWide returns the locales wide weekday given the 'weekday' provided
  164. func (or *or_IN) WeekdayWide(weekday time.Weekday) string {
  165. return or.daysWide[weekday]
  166. }
  167. // WeekdaysWide returns the locales wide weekdays
  168. func (or *or_IN) WeekdaysWide() []string {
  169. return or.daysWide
  170. }
  171. // Decimal returns the decimal point of number
  172. func (or *or_IN) Decimal() string {
  173. return or.decimal
  174. }
  175. // Group returns the group of number
  176. func (or *or_IN) Group() string {
  177. return or.group
  178. }
  179. // Group returns the minus sign of number
  180. func (or *or_IN) Minus() string {
  181. return or.minus
  182. }
  183. // FmtNumber returns 'num' with digits/precision of 'v' for 'or_IN' and handles both Whole and Real numbers based on 'v'
  184. func (or *or_IN) FmtNumber(num float64, v uint64) string {
  185. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  186. l := len(s) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  187. count := 0
  188. inWhole := v == 0
  189. inSecondary := false
  190. groupThreshold := 3
  191. b := make([]byte, 0, l)
  192. for i := len(s) - 1; i >= 0; i-- {
  193. if s[i] == '.' {
  194. b = append(b, or.decimal[0])
  195. inWhole = true
  196. continue
  197. }
  198. if inWhole {
  199. if count == groupThreshold {
  200. b = append(b, or.group[0])
  201. count = 1
  202. if !inSecondary {
  203. inSecondary = true
  204. groupThreshold = 2
  205. }
  206. } else {
  207. count++
  208. }
  209. }
  210. b = append(b, s[i])
  211. }
  212. if num < 0 {
  213. b = append(b, or.minus[0])
  214. }
  215. // reverse
  216. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  217. b[i], b[j] = b[j], b[i]
  218. }
  219. return string(b)
  220. }
  221. // FmtPercent returns 'num' with digits/precision of 'v' for 'or_IN' and handles both Whole and Real numbers based on 'v'
  222. // NOTE: 'num' passed into FmtPercent is assumed to be in percent already
  223. func (or *or_IN) FmtPercent(num float64, v uint64) string {
  224. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  225. l := len(s) + 3
  226. b := make([]byte, 0, l)
  227. for i := len(s) - 1; i >= 0; i-- {
  228. if s[i] == '.' {
  229. b = append(b, or.decimal[0])
  230. continue
  231. }
  232. b = append(b, s[i])
  233. }
  234. if num < 0 {
  235. b = append(b, or.minus[0])
  236. }
  237. // reverse
  238. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  239. b[i], b[j] = b[j], b[i]
  240. }
  241. b = append(b, or.percent...)
  242. return string(b)
  243. }
  244. // FmtCurrency returns the currency representation of 'num' with digits/precision of 'v' for 'or_IN'
  245. func (or *or_IN) FmtCurrency(num float64, v uint64, currency currency.Type) string {
  246. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  247. symbol := or.currencies[currency]
  248. l := len(s) + len(symbol) + 2 + 1*len(s[:len(s)-int(v)-1])/3
  249. count := 0
  250. inWhole := v == 0
  251. inSecondary := false
  252. groupThreshold := 3
  253. b := make([]byte, 0, l)
  254. for i := len(s) - 1; i >= 0; i-- {
  255. if s[i] == '.' {
  256. b = append(b, or.decimal[0])
  257. inWhole = true
  258. continue
  259. }
  260. if inWhole {
  261. if count == groupThreshold {
  262. b = append(b, or.group[0])
  263. count = 1
  264. if !inSecondary {
  265. inSecondary = true
  266. groupThreshold = 2
  267. }
  268. } else {
  269. count++
  270. }
  271. }
  272. b = append(b, s[i])
  273. }
  274. for j := len(symbol) - 1; j >= 0; j-- {
  275. b = append(b, symbol[j])
  276. }
  277. if num < 0 {
  278. b = append(b, or.minus[0])
  279. }
  280. // reverse
  281. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  282. b[i], b[j] = b[j], b[i]
  283. }
  284. if int(v) < 2 {
  285. if v == 0 {
  286. b = append(b, or.decimal...)
  287. }
  288. for i := 0; i < 2-int(v); i++ {
  289. b = append(b, '0')
  290. }
  291. }
  292. return string(b)
  293. }
  294. // FmtAccounting returns the currency representation of 'num' with digits/precision of 'v' for 'or_IN'
  295. // in accounting notation.
  296. func (or *or_IN) FmtAccounting(num float64, v uint64, currency currency.Type) string {
  297. s := strconv.FormatFloat(math.Abs(num), 'f', int(v), 64)
  298. symbol := or.currencies[currency]
  299. l := len(s) + len(symbol) + 4 + 1*len(s[:len(s)-int(v)-1])/3
  300. count := 0
  301. inWhole := v == 0
  302. inSecondary := false
  303. groupThreshold := 3
  304. b := make([]byte, 0, l)
  305. for i := len(s) - 1; i >= 0; i-- {
  306. if s[i] == '.' {
  307. b = append(b, or.decimal[0])
  308. inWhole = true
  309. continue
  310. }
  311. if inWhole {
  312. if count == groupThreshold {
  313. b = append(b, or.group[0])
  314. count = 1
  315. if !inSecondary {
  316. inSecondary = true
  317. groupThreshold = 2
  318. }
  319. } else {
  320. count++
  321. }
  322. }
  323. b = append(b, s[i])
  324. }
  325. if num < 0 {
  326. for j := len(symbol) - 1; j >= 0; j-- {
  327. b = append(b, symbol[j])
  328. }
  329. b = append(b, or.currencyNegativePrefix[0])
  330. } else {
  331. for j := len(symbol) - 1; j >= 0; j-- {
  332. b = append(b, symbol[j])
  333. }
  334. }
  335. // reverse
  336. for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
  337. b[i], b[j] = b[j], b[i]
  338. }
  339. if int(v) < 2 {
  340. if v == 0 {
  341. b = append(b, or.decimal...)
  342. }
  343. for i := 0; i < 2-int(v); i++ {
  344. b = append(b, '0')
  345. }
  346. }
  347. if num < 0 {
  348. b = append(b, or.currencyNegativeSuffix...)
  349. }
  350. return string(b)
  351. }
  352. // FmtDateShort returns the short date representation of 't' for 'or_IN'
  353. func (or *or_IN) FmtDateShort(t time.Time) string {
  354. b := make([]byte, 0, 32)
  355. b = strconv.AppendInt(b, int64(t.Month()), 10)
  356. b = append(b, []byte{0x2f}...)
  357. b = strconv.AppendInt(b, int64(t.Day()), 10)
  358. b = append(b, []byte{0x2f}...)
  359. if t.Year() > 9 {
  360. b = append(b, strconv.Itoa(t.Year())[2:]...)
  361. } else {
  362. b = append(b, strconv.Itoa(t.Year())[1:]...)
  363. }
  364. return string(b)
  365. }
  366. // FmtDateMedium returns the medium date representation of 't' for 'or_IN'
  367. func (or *or_IN) FmtDateMedium(t time.Time) string {
  368. b := make([]byte, 0, 32)
  369. b = append(b, or.monthsAbbreviated[t.Month()]...)
  370. b = append(b, []byte{0x20}...)
  371. b = strconv.AppendInt(b, int64(t.Day()), 10)
  372. b = append(b, []byte{0x2c, 0x20}...)
  373. if t.Year() > 0 {
  374. b = strconv.AppendInt(b, int64(t.Year()), 10)
  375. } else {
  376. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  377. }
  378. return string(b)
  379. }
  380. // FmtDateLong returns the long date representation of 't' for 'or_IN'
  381. func (or *or_IN) FmtDateLong(t time.Time) string {
  382. b := make([]byte, 0, 32)
  383. b = append(b, or.monthsWide[t.Month()]...)
  384. b = append(b, []byte{0x20}...)
  385. b = strconv.AppendInt(b, int64(t.Day()), 10)
  386. b = append(b, []byte{0x2c, 0x20}...)
  387. if t.Year() > 0 {
  388. b = strconv.AppendInt(b, int64(t.Year()), 10)
  389. } else {
  390. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  391. }
  392. return string(b)
  393. }
  394. // FmtDateFull returns the full date representation of 't' for 'or_IN'
  395. func (or *or_IN) FmtDateFull(t time.Time) string {
  396. b := make([]byte, 0, 32)
  397. b = append(b, or.daysWide[t.Weekday()]...)
  398. b = append(b, []byte{0x2c, 0x20}...)
  399. b = append(b, or.monthsWide[t.Month()]...)
  400. b = append(b, []byte{0x20}...)
  401. b = strconv.AppendInt(b, int64(t.Day()), 10)
  402. b = append(b, []byte{0x2c, 0x20}...)
  403. if t.Year() > 0 {
  404. b = strconv.AppendInt(b, int64(t.Year()), 10)
  405. } else {
  406. b = strconv.AppendInt(b, int64(-t.Year()), 10)
  407. }
  408. return string(b)
  409. }
  410. // FmtTimeShort returns the short time representation of 't' for 'or_IN'
  411. func (or *or_IN) FmtTimeShort(t time.Time) string {
  412. b := make([]byte, 0, 32)
  413. h := t.Hour()
  414. if h > 12 {
  415. h -= 12
  416. }
  417. b = strconv.AppendInt(b, int64(h), 10)
  418. b = append(b, or.timeSeparator...)
  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, or.periodsAbbreviated[0]...)
  426. } else {
  427. b = append(b, or.periodsAbbreviated[1]...)
  428. }
  429. return string(b)
  430. }
  431. // FmtTimeMedium returns the medium time representation of 't' for 'or_IN'
  432. func (or *or_IN) FmtTimeMedium(t time.Time) string {
  433. b := make([]byte, 0, 32)
  434. h := t.Hour()
  435. if h > 12 {
  436. h -= 12
  437. }
  438. b = strconv.AppendInt(b, int64(h), 10)
  439. b = append(b, or.timeSeparator...)
  440. if t.Minute() < 10 {
  441. b = append(b, '0')
  442. }
  443. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  444. b = append(b, or.timeSeparator...)
  445. if t.Second() < 10 {
  446. b = append(b, '0')
  447. }
  448. b = strconv.AppendInt(b, int64(t.Second()), 10)
  449. b = append(b, []byte{0x20}...)
  450. if t.Hour() < 12 {
  451. b = append(b, or.periodsAbbreviated[0]...)
  452. } else {
  453. b = append(b, or.periodsAbbreviated[1]...)
  454. }
  455. return string(b)
  456. }
  457. // FmtTimeLong returns the long time representation of 't' for 'or_IN'
  458. func (or *or_IN) FmtTimeLong(t time.Time) string {
  459. b := make([]byte, 0, 32)
  460. h := t.Hour()
  461. if h > 12 {
  462. h -= 12
  463. }
  464. b = strconv.AppendInt(b, int64(h), 10)
  465. b = append(b, or.timeSeparator...)
  466. if t.Minute() < 10 {
  467. b = append(b, '0')
  468. }
  469. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  470. b = append(b, or.timeSeparator...)
  471. if t.Second() < 10 {
  472. b = append(b, '0')
  473. }
  474. b = strconv.AppendInt(b, int64(t.Second()), 10)
  475. b = append(b, []byte{0x20}...)
  476. if t.Hour() < 12 {
  477. b = append(b, or.periodsAbbreviated[0]...)
  478. } else {
  479. b = append(b, or.periodsAbbreviated[1]...)
  480. }
  481. b = append(b, []byte{0x20}...)
  482. tz, _ := t.Zone()
  483. b = append(b, tz...)
  484. return string(b)
  485. }
  486. // FmtTimeFull returns the full time representation of 't' for 'or_IN'
  487. func (or *or_IN) FmtTimeFull(t time.Time) string {
  488. b := make([]byte, 0, 32)
  489. h := t.Hour()
  490. if h > 12 {
  491. h -= 12
  492. }
  493. b = strconv.AppendInt(b, int64(h), 10)
  494. b = append(b, or.timeSeparator...)
  495. if t.Minute() < 10 {
  496. b = append(b, '0')
  497. }
  498. b = strconv.AppendInt(b, int64(t.Minute()), 10)
  499. b = append(b, or.timeSeparator...)
  500. if t.Second() < 10 {
  501. b = append(b, '0')
  502. }
  503. b = strconv.AppendInt(b, int64(t.Second()), 10)
  504. b = append(b, []byte{0x20}...)
  505. if t.Hour() < 12 {
  506. b = append(b, or.periodsAbbreviated[0]...)
  507. } else {
  508. b = append(b, or.periodsAbbreviated[1]...)
  509. }
  510. b = append(b, []byte{0x20}...)
  511. tz, _ := t.Zone()
  512. if btz, ok := or.timezones[tz]; ok {
  513. b = append(b, btz...)
  514. } else {
  515. b = append(b, tz...)
  516. }
  517. return string(b)
  518. }