index.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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+)(è|r|n|r|t)?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(aC|dC)/i,
  13. abbreviated: /^(a. de C.|d. de C.)/i,
  14. wide: /^(abans de Crist|despr[eé]s de Crist)/i
  15. };
  16. var parseEraPatterns = {
  17. narrow: [/^aC/i, /^dC/i],
  18. abbreviated: [/^(a. de C.)/i, /^(d. de C.)/i],
  19. wide: [/^(abans de Crist)/i, /^(despr[eé]s de Crist)/i]
  20. };
  21. var matchQuarterPatterns = {
  22. narrow: /^[1234]/i,
  23. abbreviated: /^T[1234]/i,
  24. wide: /^[1234](è|r|n|r|t)? trimestre/i
  25. };
  26. var parseQuarterPatterns = {
  27. any: [/1/i, /2/i, /3/i, /4/i]
  28. };
  29. var matchMonthPatterns = {
  30. narrow: /^(GN|FB|MÇ|AB|MG|JN|JL|AG|ST|OC|NV|DS)/i,
  31. abbreviated: /^(gen.|febr.|març|abr.|maig|juny|jul.|ag.|set.|oct.|nov.|des.)/i,
  32. wide: /^(gener|febrer|març|abril|maig|juny|juliol|agost|setembre|octubre|novembre|desembre)/i
  33. };
  34. var parseMonthPatterns = {
  35. narrow: [/^GN/i, /^FB/i, /^MÇ/i, /^AB/i, /^MG/i, /^JN/i, /^JL/i, /^AG/i, /^ST/i, /^OC/i, /^NV/i, /^DS/i],
  36. abbreviated: [/^gen./i, /^febr./i, /^març/i, /^abr./i, /^maig/i, /^juny/i, /^jul./i, /^ag./i, /^set./i, /^oct./i, /^nov./i, /^des./i],
  37. wide: [/^gener/i, /^febrer/i, /^març/i, /^abril/i, /^maig/i, /^juny/i, /^juliol/i, /^agost/i, /^setembre/i, /^octubre/i, /^novembre/i, /^desembre/i]
  38. };
  39. var matchDayPatterns = {
  40. narrow: /^(dg\.|dl\.|dt\.|dm\.|dj\.|dv\.|ds\.)/i,
  41. short: /^(dg\.|dl\.|dt\.|dm\.|dj\.|dv\.|ds\.)/i,
  42. abbreviated: /^(dg\.|dl\.|dt\.|dm\.|dj\.|dv\.|ds\.)/i,
  43. wide: /^(diumenge|dilluns|dimarts|dimecres|dijous|divendres|dissabte)/i
  44. };
  45. var parseDayPatterns = {
  46. narrow: [/^dg./i, /^dl./i, /^dt./i, /^dm./i, /^dj./i, /^dv./i, /^ds./i],
  47. abbreviated: [/^dg./i, /^dl./i, /^dt./i, /^dm./i, /^dj./i, /^dv./i, /^ds./i],
  48. wide: [/^diumenge/i, /^dilluns/i, /^dimarts/i, /^dimecres/i, /^dijous/i, /^divendres/i, /^disssabte/i]
  49. };
  50. var matchDayPeriodPatterns = {
  51. narrow: /^(a|p|mn|md|(del|de la) (matí|tarda|vespre|nit))/i,
  52. abbreviated: /^([ap]\.?\s?m\.?|mitjanit|migdia|(del|de la) (matí|tarda|vespre|nit))/i,
  53. wide: /^(ante meridiem|post meridiem|mitjanit|migdia|(del|de la) (matí|tarda|vespre|nit))/i
  54. };
  55. var parseDayPeriodPatterns = {
  56. any: {
  57. am: /^a/i,
  58. pm: /^p/i,
  59. midnight: /^mitjanit/i,
  60. noon: /^migdia/i,
  61. morning: /matí/i,
  62. afternoon: /tarda/i,
  63. evening: /vespre/i,
  64. night: /nit/i
  65. }
  66. };
  67. var match = {
  68. ordinalNumber: (0, _index2.default)({
  69. matchPattern: matchOrdinalNumberPattern,
  70. parsePattern: parseOrdinalNumberPattern,
  71. valueCallback: function valueCallback(value) {
  72. return parseInt(value, 10);
  73. }
  74. }),
  75. era: (0, _index.default)({
  76. matchPatterns: matchEraPatterns,
  77. defaultMatchWidth: 'wide',
  78. parsePatterns: parseEraPatterns,
  79. defaultParseWidth: 'wide'
  80. }),
  81. quarter: (0, _index.default)({
  82. matchPatterns: matchQuarterPatterns,
  83. defaultMatchWidth: 'wide',
  84. parsePatterns: parseQuarterPatterns,
  85. defaultParseWidth: 'any',
  86. valueCallback: function valueCallback(index) {
  87. return index + 1;
  88. }
  89. }),
  90. month: (0, _index.default)({
  91. matchPatterns: matchMonthPatterns,
  92. defaultMatchWidth: 'wide',
  93. parsePatterns: parseMonthPatterns,
  94. defaultParseWidth: 'wide'
  95. }),
  96. day: (0, _index.default)({
  97. matchPatterns: matchDayPatterns,
  98. defaultMatchWidth: 'wide',
  99. parsePatterns: parseDayPatterns,
  100. defaultParseWidth: 'wide'
  101. }),
  102. dayPeriod: (0, _index.default)({
  103. matchPatterns: matchDayPeriodPatterns,
  104. defaultMatchWidth: 'wide',
  105. parsePatterns: parseDayPeriodPatterns,
  106. defaultParseWidth: 'any'
  107. })
  108. };
  109. var _default = match;
  110. exports.default = _default;
  111. module.exports = exports.default;