index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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+)(chi)?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(m\.a|m\.)/i,
  13. abbreviated: /^(m\.a\.?\s?m\.?)/i,
  14. wide: /^(miloddan avval|miloddan keyin)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^b/i, /^(a|c)/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^[1234]/i,
  21. abbreviated: /^q[1234]/i,
  22. wide: /^[1234](chi)? chorak/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/1/i, /2/i, /3/i, /4/i]
  26. };
  27. var matchMonthPatterns = {
  28. narrow: /^[yfmasond]/i,
  29. abbreviated: /^(yan|fev|mar|apr|may|iyun|iyul|avg|sen|okt|noy|dek)/i,
  30. wide: /^(yanvar|fevral|mart|aprel|may|iyun|iyul|avgust|sentabr|oktabr|noyabr|dekabr)/i
  31. };
  32. var parseMonthPatterns = {
  33. narrow: [/^y/i, /^f/i, /^m/i, /^a/i, /^m/i, /^i/i, /^i/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
  34. any: [/^ya/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^iyun/i, /^iyul/i, /^av/i, /^s/i, /^o/i, /^n/i, /^d/i]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[ydschj]/i,
  38. short: /^(ya|du|se|cho|pa|ju|sha)/i,
  39. abbreviated: /^(yak|dush|sesh|chor|pay|jum|shan)/i,
  40. wide: /^(yakshanba|dushanba|seshanba|chorshanba|payshanba|juma|shanba)/i
  41. };
  42. var parseDayPatterns = {
  43. narrow: [/^y/i, /^d/i, /^s/i, /^ch/i, /^p/i, /^j/i, /^sh/i],
  44. any: [/^ya/i, /^d/i, /^se/i, /^ch/i, /^p/i, /^j/i, /^sh/i]
  45. };
  46. var matchDayPeriodPatterns = {
  47. narrow: /^(a|p|y\.t|p| (ertalab|tushdan keyin|kechqurun|tun))/i,
  48. any: /^([ap]\.?\s?m\.?|yarim tun|peshin| (ertalab|tushdan keyin|kechqurun|tun))/i
  49. };
  50. var parseDayPeriodPatterns = {
  51. any: {
  52. am: /^a/i,
  53. pm: /^p/i,
  54. midnight: /^y\.t/i,
  55. noon: /^pe/i,
  56. morning: /ertalab/i,
  57. afternoon: /tushdan keyin/i,
  58. evening: /kechqurun/i,
  59. night: /tun/i
  60. }
  61. };
  62. var match = {
  63. ordinalNumber: (0, _index.default)({
  64. matchPattern: matchOrdinalNumberPattern,
  65. parsePattern: parseOrdinalNumberPattern,
  66. valueCallback: function (value) {
  67. return parseInt(value, 10);
  68. }
  69. }),
  70. era: (0, _index2.default)({
  71. matchPatterns: matchEraPatterns,
  72. defaultMatchWidth: 'wide',
  73. parsePatterns: parseEraPatterns,
  74. defaultParseWidth: 'any'
  75. }),
  76. quarter: (0, _index2.default)({
  77. matchPatterns: matchQuarterPatterns,
  78. defaultMatchWidth: 'wide',
  79. parsePatterns: parseQuarterPatterns,
  80. defaultParseWidth: 'any',
  81. valueCallback: function (index) {
  82. return index + 1;
  83. }
  84. }),
  85. month: (0, _index2.default)({
  86. matchPatterns: matchMonthPatterns,
  87. defaultMatchWidth: 'wide',
  88. parsePatterns: parseMonthPatterns,
  89. defaultParseWidth: 'any'
  90. }),
  91. day: (0, _index2.default)({
  92. matchPatterns: matchDayPatterns,
  93. defaultMatchWidth: 'wide',
  94. parsePatterns: parseDayPatterns,
  95. defaultParseWidth: 'any'
  96. }),
  97. dayPeriod: (0, _index2.default)({
  98. matchPatterns: matchDayPeriodPatterns,
  99. defaultMatchWidth: 'any',
  100. parsePatterns: parseDayPeriodPatterns,
  101. defaultParseWidth: 'any'
  102. })
  103. };
  104. var _default = match;
  105. exports.default = _default;
  106. module.exports = exports.default;