index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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+)[ºªo]?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(ac|dc|a|d)/i,
  13. abbreviated: /^(a\.?\s?c\.?|d\.?\s?c\.?)/i,
  14. wide: /^(antes de cristo|depois de cristo)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^ac/i, /^dc/i],
  18. wide: [/^antes de cristo/i, /^depois de cristo/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: /^[jfmajsond]/i,
  30. abbreviated: /^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,
  31. wide: /^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i
  32. };
  33. var parseMonthPatterns = {
  34. narrow: [/^j/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: [/^ja/i, /^fev/i, /^mar/i, /^abr/i, /^mai/i, /^jun/i, /^jul/i, /^ago/i, /^set/i, /^out/i, /^nov/i, /^dez/i]
  36. };
  37. var matchDayPatterns = {
  38. narrow: /^(dom|[23456]ª?|s[aá]b)/i,
  39. short: /^(dom|[23456]ª?|s[aá]b)/i,
  40. abbreviated: /^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,
  41. wide: /^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i
  42. };
  43. var parseDayPatterns = {
  44. short: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
  45. narrow: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
  46. any: [/^d/i, /^seg/i, /^t/i, /^qua/i, /^qui/i, /^sex/i, /^s[aá]b/i]
  47. };
  48. var matchDayPeriodPatterns = {
  49. narrow: /^(a|p|mn|md|(da) (manhã|tarde|noite))/i,
  50. any: /^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i
  51. };
  52. var parseDayPeriodPatterns = {
  53. any: {
  54. am: /^a/i,
  55. pm: /^p/i,
  56. midnight: /^mn|^meia[-\s]noite/i,
  57. noon: /^md|^meio[-\s]dia/i,
  58. morning: /manhã/i,
  59. afternoon: /tarde/i,
  60. evening: /tarde/i,
  61. night: /noite/i
  62. }
  63. };
  64. var match = {
  65. ordinalNumber: (0, _index2.default)({
  66. matchPattern: matchOrdinalNumberPattern,
  67. parsePattern: parseOrdinalNumberPattern,
  68. valueCallback: function valueCallback(value) {
  69. return parseInt(value, 10);
  70. }
  71. }),
  72. era: (0, _index.default)({
  73. matchPatterns: matchEraPatterns,
  74. defaultMatchWidth: 'wide',
  75. parsePatterns: parseEraPatterns,
  76. defaultParseWidth: 'any'
  77. }),
  78. quarter: (0, _index.default)({
  79. matchPatterns: matchQuarterPatterns,
  80. defaultMatchWidth: 'wide',
  81. parsePatterns: parseQuarterPatterns,
  82. defaultParseWidth: 'any',
  83. valueCallback: function valueCallback(index) {
  84. return index + 1;
  85. }
  86. }),
  87. month: (0, _index.default)({
  88. matchPatterns: matchMonthPatterns,
  89. defaultMatchWidth: 'wide',
  90. parsePatterns: parseMonthPatterns,
  91. defaultParseWidth: 'any'
  92. }),
  93. day: (0, _index.default)({
  94. matchPatterns: matchDayPatterns,
  95. defaultMatchWidth: 'wide',
  96. parsePatterns: parseDayPatterns,
  97. defaultParseWidth: 'any'
  98. }),
  99. dayPeriod: (0, _index.default)({
  100. matchPatterns: matchDayPeriodPatterns,
  101. defaultMatchWidth: 'any',
  102. parsePatterns: parseDayPeriodPatterns,
  103. defaultParseWidth: 'any'
  104. })
  105. };
  106. var _default = match;
  107. exports.default = _default;
  108. module.exports = exports.default;