index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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: /^(f\.? ?Kr\.?|fvt\.?|e\.? ?Kr\.?|evt\.?)/i,
  13. abbreviated: /^(f\.? ?Kr\.?|fvt\.?|e\.? ?Kr\.?|evt\.?)/i,
  14. wide: /^(før Kristus|før vår tid|etter Kristus|vår tid)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^f/i, /^e/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^q[1234]/i,
  22. wide: /^[1234](\.)? kvartal/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|mars?|apr|mai|juni?|juli?|aug|sep|okt|nov|des)\.?/i,
  30. wide: /^(januar|februar|mars|april|mai|juni|juli|august|september|oktober|november|desember)/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, /^mai/i, /^jun/i, /^jul/i, /^aug/i, /^s/i, /^o/i, /^n/i, /^d/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[smtofl]/i,
  38. short: /^(su|må|ty|on|to|fr|la)/i,
  39. abbreviated: /^(sun|mån|tys|ons|tor|fre|laur)/i,
  40. wide: /^(sundag|måndag|tysdag|onsdag|torsdag|fredag|laurdag)/i
  41. };
  42. var parseDayPatterns = {
  43. any: [/^s/i, /^m/i, /^ty/i, /^o/i, /^to/i, /^f/i, /^l/i]
  44. };
  45. var matchDayPeriodPatterns = {
  46. narrow: /^(midnatt|middag|(på) (morgonen|ettermiddagen|kvelden|natta)|[ap])/i,
  47. any: /^([ap]\.?\s?m\.?|midnatt|middag|(på) (morgonen|ettermiddagen|kvelden|natta))/i
  48. };
  49. var parseDayPeriodPatterns = {
  50. any: {
  51. am: /^a(\.?\s?m\.?)?$/i,
  52. pm: /^p(\.?\s?m\.?)?$/i,
  53. midnight: /^midn/i,
  54. noon: /^midd/i,
  55. morning: /morgon/i,
  56. afternoon: /ettermiddag/i,
  57. evening: /kveld/i,
  58. night: /natt/i
  59. }
  60. };
  61. var match = {
  62. ordinalNumber: (0, _index.default)({
  63. matchPattern: matchOrdinalNumberPattern,
  64. parsePattern: parseOrdinalNumberPattern,
  65. valueCallback: function (value) {
  66. return parseInt(value, 10);
  67. }
  68. }),
  69. era: (0, _index2.default)({
  70. matchPatterns: matchEraPatterns,
  71. defaultMatchWidth: 'wide',
  72. parsePatterns: parseEraPatterns,
  73. defaultParseWidth: 'any'
  74. }),
  75. quarter: (0, _index2.default)({
  76. matchPatterns: matchQuarterPatterns,
  77. defaultMatchWidth: 'wide',
  78. parsePatterns: parseQuarterPatterns,
  79. defaultParseWidth: 'any',
  80. valueCallback: function (index) {
  81. return index + 1;
  82. }
  83. }),
  84. month: (0, _index2.default)({
  85. matchPatterns: matchMonthPatterns,
  86. defaultMatchWidth: 'wide',
  87. parsePatterns: parseMonthPatterns,
  88. defaultParseWidth: 'any'
  89. }),
  90. day: (0, _index2.default)({
  91. matchPatterns: matchDayPatterns,
  92. defaultMatchWidth: 'wide',
  93. parsePatterns: parseDayPatterns,
  94. defaultParseWidth: 'any'
  95. }),
  96. dayPeriod: (0, _index2.default)({
  97. matchPatterns: matchDayPeriodPatterns,
  98. defaultMatchWidth: 'any',
  99. parsePatterns: parseDayPeriodPatterns,
  100. defaultParseWidth: 'any'
  101. })
  102. };
  103. var _default = match;
  104. exports.default = _default;
  105. module.exports = exports.default;