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/buildMatchFn/index.js"));
  7. var _index2 = _interopRequireDefault(require("../../../_lib/buildMatchPatternFn/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: /^(pr\.n\.e\.|AD)/i,
  13. abbreviated: /^(pr\.\s?Hr\.|po\.\s?Hr\.)/i,
  14. wide: /^(Pre Hrista|pre nove ere|Posle Hrista|nova era)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^pr/i, /^(po|nova)/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^[1234]\.\s?kv\.?/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: /^(10|11|12|[123456789])\./i,
  29. abbreviated: /^(jan|feb|mar|apr|maj|jun|jul|avg|sep|okt|nov|dec)/i,
  30. wide: /^((januar|januara)|(februar|februara)|(mart|marta)|(april|aprila)|(maj|maja)|(jun|juna)|(jul|jula)|(avgust|avgusta)|(septembar|septembra)|(oktobar|oktobra)|(novembar|novembra)|(decembar|decembra))/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/(10|11|12|[123456789])/i],
  34. any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^maj/i, /^jun/i, /^jul/i, /^avg/i, /^s/i, /^o/i, /^n/i, /^d/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[npusčc]/i,
  38. short: /^(ned|pon|uto|sre|(čet|cet)|pet|sub)/i,
  39. abbreviated: /^(ned|pon|uto|sre|(čet|cet)|pet|sub)/i,
  40. wide: /^(nedelja|ponedeljak|utorak|sreda|(četvrtak|cetvrtak)|petak|subota)/i
  41. };
  42. var parseDayPatterns = {
  43. narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
  44. any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
  45. };
  46. var matchDayPeriodPatterns = {
  47. any: /^(am|pm|ponoc|ponoć|(po)?podne|uvece|uveče|noću|posle podne|ujutru)/i
  48. };
  49. var parseDayPeriodPatterns = {
  50. any: {
  51. am: /^a/i,
  52. pm: /^p/i,
  53. midnight: /^pono/i,
  54. noon: /^pod/i,
  55. morning: /jutro/i,
  56. afternoon: /(posle\s|po)+podne/i,
  57. evening: /(uvece|uveče)/i,
  58. night: /(nocu|noću)/i
  59. }
  60. };
  61. var match = {
  62. ordinalNumber: (0, _index2.default)({
  63. matchPattern: matchOrdinalNumberPattern,
  64. parsePattern: parseOrdinalNumberPattern,
  65. valueCallback: function (value) {
  66. return parseInt(value, 10);
  67. }
  68. }),
  69. era: (0, _index.default)({
  70. matchPatterns: matchEraPatterns,
  71. defaultMatchWidth: 'wide',
  72. parsePatterns: parseEraPatterns,
  73. defaultParseWidth: 'any'
  74. }),
  75. quarter: (0, _index.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, _index.default)({
  85. matchPatterns: matchMonthPatterns,
  86. defaultMatchWidth: 'wide',
  87. parsePatterns: parseMonthPatterns,
  88. defaultParseWidth: 'any'
  89. }),
  90. day: (0, _index.default)({
  91. matchPatterns: matchDayPatterns,
  92. defaultMatchWidth: 'wide',
  93. parsePatterns: parseDayPatterns,
  94. defaultParseWidth: 'any'
  95. }),
  96. dayPeriod: (0, _index.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;