index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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|nd|en)?[a]?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(ab\.J\.C|apr\.J\.C|apr\.J\.-C)/i,
  13. abbreviated: /^(ab\.J\.-C|ab\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i,
  14. wide: /^(abans Jèsus-Crist|après Jèsus-Crist)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^ab/i, /^ap/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^T[1234]/i,
  21. abbreviated: /^[1234](èr|nd|en)? trim\.?/i,
  22. wide: /^[1234](èr|nd|en)? trimèstre/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^(GN|FB|MÇ|AB|MA|JN|JL|AG|ST|OC|NV|DC)/i,
  29. abbreviated: /^(gen|febr|març|abr|mai|junh|jul|ag|set|oct|nov|dec)\.?/i,
  30. wide: /^(genièr|febrièr|març|abril|mai|junh|julhet|agost|setembre|octòbre|novembre|decembre)/i
  31. };
  32. var parseMonthPatterns = {
  33. any: [/^g/i, /^f/i, /^ma[r?]|MÇ/i, /^ab/i, /^ma[i?]/i, /^ju[n?]|JN/i, /^ju[l?]|JL/i, /^ag/i, /^s/i, /^o/i, /^n/i, /^d/i]
  34. };
  35. var matchDayPatterns = {
  36. narrow: /^d[glmcjvs]\.?/i,
  37. short: /^d[glmcjvs]\.?/i,
  38. abbreviated: /^d[glmcjvs]\.?/i,
  39. wide: /^(dimenge|diluns|dimars|dimècres|dijòus|divendres|dissabte)/i
  40. };
  41. var parseDayPatterns = {
  42. narrow: [/^dg/i, /^dl/i, /^dm/i, /^dc/i, /^dj/i, /^dv/i, /^ds/i],
  43. short: [/^dg/i, /^dl/i, /^dm/i, /^dc/i, /^dj/i, /^dv/i, /^ds/i],
  44. abbreviated: [/^dg/i, /^dl/i, /^dm/i, /^dc/i, /^dj/i, /^dv/i, /^ds/i],
  45. any: [/^dg|dime/i, /^dl|dil/i, /^dm|dima/i, /^dc|dimè/i, /^dj|dij/i, /^dv|div/i, /^ds|dis/i]
  46. };
  47. var matchDayPeriodPatterns = {
  48. any: /(^(a\.?m|p\.?m))|(ante meridiem|post meridiem)|((del |de la |de l’)(matin|aprèp-miègjorn|vèspre|ser|nuèch))/i
  49. };
  50. var parseDayPeriodPatterns = {
  51. any: {
  52. am: /(^a)|ante meridiem/i,
  53. pm: /(^p)|post meridiem/i,
  54. midnight: /^mièj/i,
  55. noon: /^mièg/i,
  56. morning: /matin/i,
  57. afternoon: /aprèp-miègjorn/i,
  58. evening: /vèspre|ser/i,
  59. night: /nuèch/i
  60. }
  61. };
  62. var match = {
  63. ordinalNumber: (0, _index2.default)({
  64. matchPattern: matchOrdinalNumberPattern,
  65. parsePattern: parseOrdinalNumberPattern,
  66. valueCallback: function valueCallback(value) {
  67. return parseInt(value, 10);
  68. }
  69. }),
  70. era: (0, _index.default)({
  71. matchPatterns: matchEraPatterns,
  72. defaultMatchWidth: 'wide',
  73. parsePatterns: parseEraPatterns,
  74. defaultParseWidth: 'any'
  75. }),
  76. quarter: (0, _index.default)({
  77. matchPatterns: matchQuarterPatterns,
  78. defaultMatchWidth: 'wide',
  79. parsePatterns: parseQuarterPatterns,
  80. defaultParseWidth: 'any',
  81. valueCallback: function valueCallback(index) {
  82. return index + 1;
  83. }
  84. }),
  85. month: (0, _index.default)({
  86. matchPatterns: matchMonthPatterns,
  87. defaultMatchWidth: 'wide',
  88. parsePatterns: parseMonthPatterns,
  89. defaultParseWidth: 'any'
  90. }),
  91. day: (0, _index.default)({
  92. matchPatterns: matchDayPatterns,
  93. defaultMatchWidth: 'wide',
  94. parsePatterns: parseDayPatterns,
  95. defaultParseWidth: 'any'
  96. }),
  97. dayPeriod: (0, _index.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;