index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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+)\.?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(p[řr](\.|ed) Kr\.|p[řr](\.|ed) n\. l\.|po Kr\.|n\. l\.)/i,
  13. abbreviated: /^(p[řr](\.|ed) Kr\.|p[řr](\.|ed) n\. l\.|po Kr\.|n\. l\.)/i,
  14. wide: /^(p[řr](\.|ed) Kristem|p[řr](\.|ed) na[šs][íi]m letopo[čc]tem|po Kristu|na[šs]eho letopo[čc]tu)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^p[řr]/i, /^(po|n)/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^[1234]\. [čc]tvrtlet[íi]/i,
  22. wide: /^[1234]\. [čc]tvrtlet[íi]/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^[lúubdkčcszřrlp]/i,
  29. abbreviated: /^(led|[úu]no|b[řr]e|dub|kv[ěe]|[čc]vn|[čc]vc|srp|z[áa][řr]|[řr][íi]j|lis|pro)/i,
  30. wide: /^(leden|ledna|[úu]nora?|b[řr]ezen|b[řr]ezna|duben|dubna|kv[ěe]ten|kv[ěe]tna|[čc]erven(ec|ce)?|[čc]ervna|srpen|srpna|z[áa][řr][íi]|[řr][íi]jen|[řr][íi]jna|listopad(a|u)?|prosinec|prosince)/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/^l/i, /^[úu]/i, /^b/i, /^d/i, /^k/i, /^[čc]/i, /^[čc]/i, /^s/i, /^z/i, /^[řr]/i, /^l/i, /^p/i],
  34. any: [/^led/i, /^[úu]n/i, /^b[řr]e/i, /^dub/i, /^kv[ěe]/i, /^[čc]vn|[čc]erven(?!\w)|[čc]ervna/i, /^[čc]vc|[čc]erven(ec|ce)/i, /^srp/i, /^z[áa][řr]/i, /^[řr][íi]j/i, /^lis/i, /^pro/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[npuúsčps]/i,
  38. short: /^(ne|po|[úu]t|st|[čc]t|p[áa]|so)/i,
  39. abbreviated: /^(ned|pon|[úu]te|st[rř]|[čc]tv|p[áa]t|sob)/i,
  40. wide: /^(ned[ěe]le|pond[ěe]l[íi]|[úu]ter[ýy]|st[řr]eda|[čc]tvrtek|p[áa]tek|sobota)/i
  41. };
  42. var parseDayPatterns = {
  43. narrow: [/^n/i, /^p/i, /^[úu]/i, /^s/i, /^[čc]/i, /^p/i, /^s/i],
  44. any: [/^ne/i, /^po/i, /^[úu]t/i, /^st/i, /^[čc]t/i, /^p[áa]/i, /^so/i]
  45. };
  46. var matchDayPeriodPatterns = {
  47. any: /^dopoledne|dop\.?|odpoledne|odp\.?|p[ůu]lnoc|poledne|r[áa]no|odpoledne|ve[čc]er|(v )?noci?/i
  48. };
  49. var parseDayPeriodPatterns = {
  50. any: {
  51. am: /^dop/i,
  52. pm: /^odp/i,
  53. midnight: /^p[ůu]lnoc/i,
  54. noon: /^poledne/i,
  55. morning: /r[áa]no/i,
  56. afternoon: /odpoledne/i,
  57. evening: /ve[čc]er/i,
  58. night: /noc/i
  59. }
  60. };
  61. var match = {
  62. ordinalNumber: (0, _index2.default)({
  63. matchPattern: matchOrdinalNumberPattern,
  64. parsePattern: parseOrdinalNumberPattern,
  65. valueCallback: function valueCallback(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 valueCallback(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;