index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _index = _interopRequireDefault(require("../../../_lib/buildMatchPatternFn/index.js"));
  7. var _index2 = _interopRequireDefault(require("../../../_lib/buildMatchFn/index.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. var matchOrdinalNumberPattern = /^(\d+)(-?(е|я|га|і|ы|ае|ая|яя|шы|гі|ці|ты|мы))?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^((да )?н\.?\s?э\.?)/i,
  13. abbreviated: /^((да )?н\.?\s?э\.?)/i,
  14. wide: /^(да нашай эры|нашай эры|наша эра)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^д/i, /^н/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^[1234](-?[ыі]?)? кв.?/i,
  22. wide: /^[1234](-?[ыі]?)? квартал/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^[слкмчжв]/i,
  29. abbreviated: /^(студз|лют|сак|крас|ма[йя]|чэрв|ліп|жн|вер|кастр|ліст|снеж)\.?/i,
  30. wide: /^(студзен[ья]|лют(ы|ага)|сакавіка?|красавіка?|ма[йя]|чэрвен[ья]|ліпен[ья]|жні(вень|ўня)|верас(ень|ня)|кастрычніка?|лістапада?|снеж(ань|ня))/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/^с/i, /^л/i, /^с/i, /^к/i, /^м/i, /^ч/i, /^л/i, /^ж/i, /^в/i, /^к/i, /^л/i, /^с/i],
  34. any: [/^ст/i, /^лю/i, /^са/i, /^кр/i, /^ма/i, /^ч/i, /^ліп/i, /^ж/i, /^в/i, /^ка/i, /^ліс/i, /^сн/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[нпасч]/i,
  38. short: /^(нд|ня|пн|па|аў|ат|ср|се|чц|ча|пт|пя|сб|су)\.?/i,
  39. abbreviated: /^(нядз?|ндз|пнд|пан|аўт|срд|сер|чцв|чац|птн|пят|суб).?/i,
  40. wide: /^(нядзел[яі]|панядзел(ак|ка)|аўтор(ак|ка)|серад[аы]|чацв(ер|ярга)|пятніц[аы]|субот[аы])/i
  41. };
  42. var parseDayPatterns = {
  43. narrow: [/^н/i, /^п/i, /^а/i, /^с/i, /^ч/i, /^п/i, /^с/i],
  44. any: [/^н/i, /^п[ан]/i, /^а/i, /^с[ер]/i, /^ч/i, /^п[ят]/i, /^с[уб]/i]
  45. };
  46. var matchDayPeriodPatterns = {
  47. narrow: /^([дп]п|поўн\.?|поўд\.?|ран\.?|дзень|дня|веч\.?|ночы?)/i,
  48. abbreviated: /^([дп]п|поўн\.?|поўд\.?|ран\.?|дзень|дня|веч\.?|ночы?)/i,
  49. wide: /^([дп]п|поўнач|поўдзень|раніц[аы]|дзень|дня|вечара?|ночы?)/i
  50. };
  51. var parseDayPeriodPatterns = {
  52. any: {
  53. am: /^дп/i,
  54. pm: /^пп/i,
  55. midnight: /^поўн/i,
  56. noon: /^поўд/i,
  57. morning: /^р/i,
  58. afternoon: /^д[зн]/i,
  59. evening: /^в/i,
  60. night: /^н/i
  61. }
  62. };
  63. var match = {
  64. ordinalNumber: (0, _index.default)({
  65. matchPattern: matchOrdinalNumberPattern,
  66. parsePattern: parseOrdinalNumberPattern,
  67. valueCallback: function (value) {
  68. return parseInt(value, 10);
  69. }
  70. }),
  71. era: (0, _index2.default)({
  72. matchPatterns: matchEraPatterns,
  73. defaultMatchWidth: 'wide',
  74. parsePatterns: parseEraPatterns,
  75. defaultParseWidth: 'any'
  76. }),
  77. quarter: (0, _index2.default)({
  78. matchPatterns: matchQuarterPatterns,
  79. defaultMatchWidth: 'wide',
  80. parsePatterns: parseQuarterPatterns,
  81. defaultParseWidth: 'any',
  82. valueCallback: function (index) {
  83. return index + 1;
  84. }
  85. }),
  86. month: (0, _index2.default)({
  87. matchPatterns: matchMonthPatterns,
  88. defaultMatchWidth: 'wide',
  89. parsePatterns: parseMonthPatterns,
  90. defaultParseWidth: 'any'
  91. }),
  92. day: (0, _index2.default)({
  93. matchPatterns: matchDayPatterns,
  94. defaultMatchWidth: 'wide',
  95. parsePatterns: parseDayPatterns,
  96. defaultParseWidth: 'any'
  97. }),
  98. dayPeriod: (0, _index2.default)({
  99. matchPatterns: matchDayPeriodPatterns,
  100. defaultMatchWidth: 'wide',
  101. parsePatterns: parseDayPeriodPatterns,
  102. defaultParseWidth: 'any'
  103. })
  104. };
  105. var _default = match;
  106. exports.default = _default;
  107. module.exports = exports.default;