index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _index = _interopRequireDefault(require("../../../_lib/buildMatchFn/index.js"));
  8. var _index2 = _interopRequireDefault(require("../../../_lib/buildMatchPatternFn/index.js"));
  9. var matchOrdinalNumberPattern = /^(\d+)?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(p\.?\s*n\.?\s*e\.?\s*|n\.?\s*e\.?\s*)/i,
  13. abbreviated: /^(p\.?\s*n\.?\s*e\.?\s*|n\.?\s*e\.?\s*)/i,
  14. wide: /^(przed\s*nasz(ą|a)\s*er(ą|a)|naszej\s*ery)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^p/i, /^n/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^(I|II|III|IV)\s*kw\.?/i,
  22. wide: /^(I|II|III|IV)\s*kwarta(ł|l)/i
  23. };
  24. var parseQuarterPatterns = {
  25. narrow: [/1/i, /2/i, /3/i, /4/i],
  26. any: [/^I kw/i, /^II kw/i, /^III kw/i, /^IV kw/i]
  27. };
  28. var matchMonthPatterns = {
  29. narrow: /^[slmkcwpg]/i,
  30. abbreviated: /^(sty|lut|mar|kwi|maj|cze|lip|sie|wrz|pa(ź|z)|lis|gru)/i,
  31. wide: /^(stycznia|stycze(ń|n)|lutego|luty|marca|marzec|kwietnia|kwiecie(ń|n)|maja|maj|czerwca|czerwiec|lipca|lipiec|sierpnia|sierpie(ń|n)|wrze(ś|s)nia|wrzesie(ń|n)|pa(ź|z)dziernika|pa(ź|z)dziernik|listopada|listopad|grudnia|grudzie(ń|n))/i
  32. };
  33. var parseMonthPatterns = {
  34. narrow: [/^s/i, /^l/i, /^m/i, /^k/i, /^m/i, /^c/i, /^l/i, /^s/i, /^w/i, /^p/i, /^l/i, /^g/i],
  35. any: [/^st/i, /^lu/i, /^mar/i, /^k/i, /^maj/i, /^c/i, /^lip/i, /^si/i, /^w/i, /^p/i, /^lis/i, /^g/i]
  36. };
  37. var matchDayPatterns = {
  38. narrow: /^[npwścs]/i,
  39. short: /^(nie|pon|wto|(ś|s)ro|czw|pi(ą|a)|sob)/i,
  40. abbreviated: /^(niedz|pon|wt|(ś|s)r|czw|pt|sob)\.?/i,
  41. wide: /^(niedziela|poniedzia(ł|l)ek|wtorek|(ś|s)roda|czwartek|pi(ą|a)tek|sobota)/i
  42. };
  43. var parseDayPatterns = {
  44. narrow: [/^n/i, /^p/i, /^w/i, /^ś/i, /^c/i, /^p/i, /^s/i],
  45. abbreviated: [/^n/i, /^po/i, /^w/i, /^(ś|s)r/i, /^c/i, /^pt/i, /^so/i],
  46. any: [/^n/i, /^po/i, /^w/i, /^(ś|s)r/i, /^c/i, /^pi/i, /^so/i]
  47. };
  48. var matchDayPeriodPatterns = {
  49. narrow: /^(^a$|^p$|pó(ł|l)n\.?|o\s*pó(ł|l)n\.?|po(ł|l)\.?|w\s*po(ł|l)\.?|po\s*po(ł|l)\.?|rano|wiecz\.?|noc|w\s*nocy)/i,
  50. any: /^(am|pm|pó(ł|l)noc|o\s*pó(ł|l)nocy|po(ł|l)udnie|w\s*po(ł|l)udnie|popo(ł|l)udnie|po\s*po(ł|l)udniu|rano|wieczór|wieczorem|noc|w\s*nocy)/i
  51. };
  52. var parseDayPeriodPatterns = {
  53. narrow: {
  54. am: /^a$/i,
  55. pm: /^p$/i,
  56. midnight: /pó(ł|l)n/i,
  57. noon: /po(ł|l)/i,
  58. morning: /rano/i,
  59. afternoon: /po\s*po(ł|l)/i,
  60. evening: /wiecz/i,
  61. night: /noc/i
  62. },
  63. any: {
  64. am: /^am/i,
  65. pm: /^pm/i,
  66. midnight: /pó(ł|l)n/i,
  67. noon: /po(ł|l)/i,
  68. morning: /rano/i,
  69. afternoon: /po\s*po(ł|l)/i,
  70. evening: /wiecz/i,
  71. night: /noc/i
  72. }
  73. };
  74. var match = {
  75. ordinalNumber: (0, _index2.default)({
  76. matchPattern: matchOrdinalNumberPattern,
  77. parsePattern: parseOrdinalNumberPattern,
  78. valueCallback: function valueCallback(value) {
  79. return parseInt(value, 10);
  80. }
  81. }),
  82. era: (0, _index.default)({
  83. matchPatterns: matchEraPatterns,
  84. defaultMatchWidth: 'wide',
  85. parsePatterns: parseEraPatterns,
  86. defaultParseWidth: 'any'
  87. }),
  88. quarter: (0, _index.default)({
  89. matchPatterns: matchQuarterPatterns,
  90. defaultMatchWidth: 'wide',
  91. parsePatterns: parseQuarterPatterns,
  92. defaultParseWidth: 'any',
  93. valueCallback: function valueCallback(index) {
  94. return index + 1;
  95. }
  96. }),
  97. month: (0, _index.default)({
  98. matchPatterns: matchMonthPatterns,
  99. defaultMatchWidth: 'wide',
  100. parsePatterns: parseMonthPatterns,
  101. defaultParseWidth: 'any'
  102. }),
  103. day: (0, _index.default)({
  104. matchPatterns: matchDayPatterns,
  105. defaultMatchWidth: 'wide',
  106. parsePatterns: parseDayPatterns,
  107. defaultParseWidth: 'any'
  108. }),
  109. dayPeriod: (0, _index.default)({
  110. matchPatterns: matchDayPeriodPatterns,
  111. defaultMatchWidth: 'any',
  112. parsePatterns: parseDayPeriodPatterns,
  113. defaultParseWidth: 'any'
  114. })
  115. };
  116. var _default = match;
  117. exports.default = _default;
  118. module.exports = exports.default;