index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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+)(:a|:e)?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(f\.? ?Kr\.?|f\.? ?v\.? ?t\.?|e\.? ?Kr\.?|v\.? ?t\.?)/i,
  13. abbreviated: /^(f\.? ?Kr\.?|f\.? ?v\.? ?t\.?|e\.? ?Kr\.?|v\.? ?t\.?)/i,
  14. wide: /^(före Kristus|före vår tid|efter Kristus|vår tid)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^f/i, /^[ev]/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^q[1234]/i,
  22. wide: /^[1234](:a|:e)? kvartalet/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^[jfmasond]/i,
  29. abbreviated: /^(jan|feb|mar[s]?|apr|maj|jun[i]?|jul[i]?|aug|sep|okt|nov|dec)\.?/i,
  30. wide: /^(januari|februari|mars|april|maj|juni|juli|augusti|september|oktober|november|december)/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
  34. any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^maj/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[smtofl]/i,
  38. short: /^(sö|må|ti|on|to|fr|lö)/i,
  39. abbreviated: /^(sön|mån|tis|ons|tors|fre|lör)/i,
  40. wide: /^(söndag|måndag|tisdag|onsdag|torsdag|fredag|lördag)/i
  41. };
  42. var parseDayPatterns = {
  43. any: [/^s/i, /^m/i, /^ti/i, /^o/i, /^to/i, /^f/i, /^l/i]
  44. };
  45. var matchDayPeriodPatterns = {
  46. any: /^([fe]\.?\s?m\.?|midn(att)?|midd(ag)?|(på) (morgonen|eftermiddagen|kvällen|natten))/i
  47. };
  48. var parseDayPeriodPatterns = {
  49. any: {
  50. am: /^f/i,
  51. pm: /^e/i,
  52. midnight: /^midn/i,
  53. noon: /^midd/i,
  54. morning: /morgon/i,
  55. afternoon: /eftermiddag/i,
  56. evening: /kväll/i,
  57. night: /natt/i
  58. }
  59. };
  60. var match = {
  61. ordinalNumber: (0, _index2.default)({
  62. matchPattern: matchOrdinalNumberPattern,
  63. parsePattern: parseOrdinalNumberPattern,
  64. valueCallback: function valueCallback(value) {
  65. return parseInt(value, 10);
  66. }
  67. }),
  68. era: (0, _index.default)({
  69. matchPatterns: matchEraPatterns,
  70. defaultMatchWidth: 'wide',
  71. parsePatterns: parseEraPatterns,
  72. defaultParseWidth: 'any'
  73. }),
  74. quarter: (0, _index.default)({
  75. matchPatterns: matchQuarterPatterns,
  76. defaultMatchWidth: 'wide',
  77. parsePatterns: parseQuarterPatterns,
  78. defaultParseWidth: 'any',
  79. valueCallback: function valueCallback(index) {
  80. return index + 1;
  81. }
  82. }),
  83. month: (0, _index.default)({
  84. matchPatterns: matchMonthPatterns,
  85. defaultMatchWidth: 'wide',
  86. parsePatterns: parseMonthPatterns,
  87. defaultParseWidth: 'any'
  88. }),
  89. day: (0, _index.default)({
  90. matchPatterns: matchDayPatterns,
  91. defaultMatchWidth: 'wide',
  92. parsePatterns: parseDayPatterns,
  93. defaultParseWidth: 'any'
  94. }),
  95. dayPeriod: (0, _index.default)({
  96. matchPatterns: matchDayPeriodPatterns,
  97. defaultMatchWidth: 'any',
  98. parsePatterns: parseDayPeriodPatterns,
  99. defaultParseWidth: 'any'
  100. })
  101. };
  102. var _default = match;
  103. exports.default = _default;
  104. module.exports = exports.default;