index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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: /^(k.a.|k.o.)/i,
  13. abbreviated: /^(k.a.|k.o.)/i,
  14. wide: /^(kristo aurretik|kristo ondoren)/i
  15. };
  16. var parseEraPatterns = {
  17. narrow: [/^k.a./i, /^k.o./i],
  18. abbreviated: [/^(k.a.)/i, /^(k.o.)/i],
  19. wide: [/^(kristo aurretik)/i, /^(kristo ondoren)/i]
  20. };
  21. var matchQuarterPatterns = {
  22. narrow: /^[1234]/i,
  23. abbreviated: /^[1234]H/i,
  24. wide: /^[1234](.)? hiruhilekoa/i
  25. };
  26. var parseQuarterPatterns = {
  27. any: [/1/i, /2/i, /3/i, /4/i]
  28. };
  29. var matchMonthPatterns = {
  30. narrow: /^[uomaei]/i,
  31. abbreviated: /^(urt|ots|mar|api|mai|eka|uzt|abu|ira|urr|aza|abe)/i,
  32. wide: /^(urtarrila|otsaila|martxoa|apirila|maiatza|ekaina|uztaila|abuztua|iraila|urria|azaroa|abendua)/i
  33. };
  34. var parseMonthPatterns = {
  35. narrow: [/^u/i, /^o/i, /^m/i, /^a/i, /^m/i, /^e/i, /^u/i, /^a/i, /^i/i, /^u/i, /^a/i, /^a/i],
  36. any: [/^urt/i, /^ots/i, /^mar/i, /^api/i, /^mai/i, /^eka/i, /^uzt/i, /^abu/i, /^ira/i, /^urr/i, /^aza/i, /^abe/i]
  37. };
  38. var matchDayPatterns = {
  39. narrow: /^[iaol]/i,
  40. short: /^(ig|al|as|az|og|or|lr)/i,
  41. abbreviated: /^(iga|ast|ast|ast|ost|ost|lar)/i,
  42. wide: /^(igandea|astelehena|asteartea|asteazkena|osteguna|ostirala|larunbata)/i
  43. };
  44. var parseDayPatterns = {
  45. narrow: [/^i/i, /^a/i, /^a/i, /^a/i, /^o/i, /^o/i, /^l/i],
  46. short: [/^ig/i, /^al/i, /^as/i, /^az/i, /^og/i, /^or/i, /^lr/i],
  47. abbreviated: [/^iga/i, /^ast/i, /^ast/i, /^ast/i, /^ost/i, /^ost/i, /^lar/i],
  48. wide: [/^igandea/i, /^astelehena/i, /^asteartea/i, /^asteazkena/i, /^osteguna/i, /^ostirala/i, /^larunbata/i]
  49. };
  50. var matchDayPeriodPatterns = {
  51. narrow: /^(a|p|ge|eg|((goiza|goizean)|arratsaldea|(gaua|gauean)))/i,
  52. any: /^([ap]\.?\s?m\.?|gauerdia|eguerdia|((goiza|goizean)|arratsaldea|(gaua|gauean)))/i
  53. };
  54. var parseDayPeriodPatterns = {
  55. narrow: {
  56. am: /^a/i,
  57. pm: /^p/i,
  58. midnight: /^ge/i,
  59. noon: /^eg/i,
  60. morning: /goiz/i,
  61. afternoon: /arratsaldea/i,
  62. evening: /arratsaldea/i,
  63. night: /gau/i
  64. },
  65. any: {
  66. am: /^a/i,
  67. pm: /^p/i,
  68. midnight: /^gauerdia/i,
  69. noon: /^eguerdia/i,
  70. morning: /goiz/i,
  71. afternoon: /arratsaldea/i,
  72. evening: /arratsaldea/i,
  73. night: /gau/i
  74. }
  75. };
  76. var match = {
  77. ordinalNumber: (0, _index.default)({
  78. matchPattern: matchOrdinalNumberPattern,
  79. parsePattern: parseOrdinalNumberPattern,
  80. valueCallback: function (value) {
  81. return parseInt(value, 10);
  82. }
  83. }),
  84. era: (0, _index2.default)({
  85. matchPatterns: matchEraPatterns,
  86. defaultMatchWidth: 'wide',
  87. parsePatterns: parseEraPatterns,
  88. defaultParseWidth: 'any'
  89. }),
  90. quarter: (0, _index2.default)({
  91. matchPatterns: matchQuarterPatterns,
  92. defaultMatchWidth: 'wide',
  93. parsePatterns: parseQuarterPatterns,
  94. defaultParseWidth: 'any',
  95. valueCallback: function (index) {
  96. return index + 1;
  97. }
  98. }),
  99. month: (0, _index2.default)({
  100. matchPatterns: matchMonthPatterns,
  101. defaultMatchWidth: 'wide',
  102. parsePatterns: parseMonthPatterns,
  103. defaultParseWidth: 'any'
  104. }),
  105. day: (0, _index2.default)({
  106. matchPatterns: matchDayPatterns,
  107. defaultMatchWidth: 'wide',
  108. parsePatterns: parseDayPatterns,
  109. defaultParseWidth: 'any'
  110. }),
  111. dayPeriod: (0, _index2.default)({
  112. matchPatterns: matchDayPeriodPatterns,
  113. defaultMatchWidth: 'any',
  114. parsePatterns: parseDayPeriodPatterns,
  115. defaultParseWidth: 'any'
  116. })
  117. };
  118. var _default = match;
  119. exports.default = _default;
  120. module.exports = exports.default;