index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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/buildMatchPatternFn/index.js"));
  8. var _index2 = _interopRequireDefault(require("../../../_lib/buildMatchFn/index.js"));
  9. var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(ق|ب)/i,
  13. abbreviated: /^(ق\.?\s?م\.?|ق\.?\s?م\.?\s?|a\.?\s?d\.?|c\.?\s?)/i,
  14. wide: /^(قبل الميلاد|قبل الميلاد|بعد الميلاد|بعد الميلاد)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^قبل/i, /^بعد/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^ر[1234]/i,
  22. wide: /^الربع [1234]/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^[جفمأسند]/i,
  29. abbreviated: /^(جان|فيف|مار|أفر|ماي|جوا|جوي|أوت|سبت|أكت|نوف|ديس)/i,
  30. wide: /^(جانفي|فيفري|مارس|أفريل|ماي|جوان|جويلية|أوت|سبتمبر|أكتوبر|نوفمبر|ديسمبر)/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/^ج/i, /^ف/i, /^م/i, /^أ/i, /^م/i, /^ج/i, /^ج/i, /^أ/i, /^س/i, /^أ/i, /^ن/i, /^د/i],
  34. any: [/^جان/i, /^فيف/i, /^مار/i, /^أفر/i, /^ماي/i, /^جوا/i, /^جوي/i, /^أوت/i, /^سبت/i, /^أكت/i, /^نوف/i, /^ديس/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[حنثرخجس]/i,
  38. short: /^(أحد|اثنين|ثلاثاء|أربعاء|خميس|جمعة|سبت)/i,
  39. abbreviated: /^(أحد|اثن|ثلا|أرب|خمي|جمعة|سبت)/i,
  40. wide: /^(الأحد|الاثنين|الثلاثاء|الأربعاء|الخميس|الجمعة|السبت)/i
  41. };
  42. var parseDayPatterns = {
  43. narrow: [/^ح/i, /^ن/i, /^ث/i, /^ر/i, /^خ/i, /^ج/i, /^س/i],
  44. wide: [/^الأحد/i, /^الاثنين/i, /^الثلاثاء/i, /^الأربعاء/i, /^الخميس/i, /^الجمعة/i, /^السبت/i],
  45. any: [/^أح/i, /^اث/i, /^ث/i, /^أر/i, /^خ/i, /^ج/i, /^س/i]
  46. };
  47. var matchDayPeriodPatterns = {
  48. narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
  49. any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
  50. };
  51. var parseDayPeriodPatterns = {
  52. any: {
  53. am: /^a/i,
  54. pm: /^p/i,
  55. midnight: /^mi/i,
  56. noon: /^no/i,
  57. morning: /morning/i,
  58. afternoon: /afternoon/i,
  59. evening: /evening/i,
  60. night: /night/i
  61. }
  62. };
  63. var match = {
  64. ordinalNumber: (0, _index.default)({
  65. matchPattern: matchOrdinalNumberPattern,
  66. parsePattern: parseOrdinalNumberPattern,
  67. valueCallback: function valueCallback(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 valueCallback(index) {
  83. return Number(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;