index.js 3.4 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: /^(ac|dc|a|d)/i,
  13. abbreviated: /^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,
  14. wide: /^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^ac/i, /^dc/i],
  18. wide: [/^(antes de cristo|antes de la era com[uú]n)/i, /^(despu[eé]s de cristo|era com[uú]n)/i]
  19. };
  20. var matchQuarterPatterns = {
  21. narrow: /^[1234]/i,
  22. abbreviated: /^T[1234]/i,
  23. wide: /^[1234](º)? trimestre/i
  24. };
  25. var parseQuarterPatterns = {
  26. any: [/1/i, /2/i, /3/i, /4/i]
  27. };
  28. var matchMonthPatterns = {
  29. narrow: /^[efmajsond]/i,
  30. abbreviated: /^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,
  31. wide: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i
  32. };
  33. var parseMonthPatterns = {
  34. narrow: [/^e/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
  35. any: [/^en/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]
  36. };
  37. var matchDayPatterns = {
  38. narrow: /^[dlmjvs]/i,
  39. short: /^(do|lu|ma|mi|ju|vi|sa)/i,
  40. abbreviated: /^(dom|lun|mar|mie|jue|vie|sab)/i,
  41. wide: /^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i
  42. };
  43. var parseDayPatterns = {
  44. narrow: [/^d/i, /^l/i, /^m/i, /^m/i, /^j/i, /^v/i, /^s/i],
  45. any: [/^do/i, /^lu/i, /^ma/i, /^mi/i, /^ju/i, /^vi/i, /^sa/i]
  46. };
  47. var matchDayPeriodPatterns = {
  48. narrow: /^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,
  49. any: /^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i
  50. };
  51. var parseDayPeriodPatterns = {
  52. any: {
  53. am: /^a/i,
  54. pm: /^p/i,
  55. midnight: /^mn/i,
  56. noon: /^md/i,
  57. morning: /mañana/i,
  58. afternoon: /tarde/i,
  59. evening: /tarde/i,
  60. night: /noche/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: 'any',
  101. parsePatterns: parseDayPeriodPatterns,
  102. defaultParseWidth: 'any'
  103. })
  104. };
  105. var _default = match;
  106. exports.default = _default;
  107. module.exports = exports.default;