index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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)/i,
  13. abbreviated: /^(a\.?\s?C\.?|a\.?\s?e\.?\s?v\.?|d\.?\s?C\.?|e\.?\s?v\.?)/i,
  14. wide: /^(avanti Cristo|avanti Era Volgare|dopo Cristo|Era Volgare)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^a/i, /^(d|e)/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^t[1234]/i,
  22. wide: /^[1234](º)? trimestre/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^[gfmalsond]/i,
  29. abbreviated: /^(gen|feb|mar|apr|mag|giu|lug|ago|set|ott|nov|dic)/i,
  30. wide: /^(gennaio|febbraio|marzo|aprile|maggio|giugno|luglio|agosto|settembre|ottobre|novembre|dicembre)/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/^g/i, /^f/i, /^m/i, /^a/i, /^m/i, /^g/i, /^l/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
  34. any: [/^ge/i, /^f/i, /^mar/i, /^ap/i, /^mag/i, /^gi/i, /^l/i, /^ag/i, /^s/i, /^o/i, /^n/i, /^d/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[dlmgvs]/i,
  38. short: /^(do|lu|ma|me|gi|ve|sa)/i,
  39. abbreviated: /^(dom|lun|mar|mer|gio|ven|sab)/i,
  40. wide: /^(domenica|luned[i|ì]|marted[i|ì]|mercoled[i|ì]|gioved[i|ì]|venerd[i|ì]|sabato)/i
  41. };
  42. var parseDayPatterns = {
  43. narrow: [/^d/i, /^l/i, /^m/i, /^m/i, /^g/i, /^v/i, /^s/i],
  44. any: [/^d/i, /^l/i, /^ma/i, /^me/i, /^g/i, /^v/i, /^s/i]
  45. };
  46. var matchDayPeriodPatterns = {
  47. narrow: /^(a|m\.|p|mezzanotte|mezzogiorno|(di|del) (mattina|pomeriggio|sera|notte))/i,
  48. any: /^([ap]\.?\s?m\.?|mezzanotte|mezzogiorno|(di|del) (mattina|pomeriggio|sera|notte))/i
  49. };
  50. var parseDayPeriodPatterns = {
  51. any: {
  52. am: /^a/i,
  53. pm: /^p/i,
  54. midnight: /^mezza/i,
  55. noon: /^mezzo/i,
  56. morning: /mattina/i,
  57. afternoon: /pomeriggio/i,
  58. evening: /sera/i,
  59. night: /notte/i
  60. }
  61. };
  62. var match = {
  63. ordinalNumber: (0, _index.default)({
  64. matchPattern: matchOrdinalNumberPattern,
  65. parsePattern: parseOrdinalNumberPattern,
  66. valueCallback: function (value) {
  67. return parseInt(value, 10);
  68. }
  69. }),
  70. era: (0, _index2.default)({
  71. matchPatterns: matchEraPatterns,
  72. defaultMatchWidth: 'wide',
  73. parsePatterns: parseEraPatterns,
  74. defaultParseWidth: 'any'
  75. }),
  76. quarter: (0, _index2.default)({
  77. matchPatterns: matchQuarterPatterns,
  78. defaultMatchWidth: 'wide',
  79. parsePatterns: parseQuarterPatterns,
  80. defaultParseWidth: 'any',
  81. valueCallback: function (index) {
  82. return index + 1;
  83. }
  84. }),
  85. month: (0, _index2.default)({
  86. matchPatterns: matchMonthPatterns,
  87. defaultMatchWidth: 'wide',
  88. parsePatterns: parseMonthPatterns,
  89. defaultParseWidth: 'any'
  90. }),
  91. day: (0, _index2.default)({
  92. matchPatterns: matchDayPatterns,
  93. defaultMatchWidth: 'wide',
  94. parsePatterns: parseDayPatterns,
  95. defaultParseWidth: 'any'
  96. }),
  97. dayPeriod: (0, _index2.default)({
  98. matchPatterns: matchDayPeriodPatterns,
  99. defaultMatchWidth: 'any',
  100. parsePatterns: parseDayPeriodPatterns,
  101. defaultParseWidth: 'any'
  102. })
  103. };
  104. var _default = match;
  105. exports.default = _default;
  106. module.exports = exports.default;