index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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: /^(B\.?C\.?|A\.?D\.?)/i,
  13. abbreviated: /^(紀元[前後]|西暦)/i,
  14. wide: /^(紀元[前後]|西暦)/i
  15. };
  16. var parseEraPatterns = {
  17. narrow: [/^B/i, /^A/i],
  18. any: [/^(紀元前)/i, /^(西暦|紀元後)/i]
  19. };
  20. var matchQuarterPatterns = {
  21. narrow: /^[1234]/i,
  22. abbreviated: /^Q[1234]/i,
  23. wide: /^第[1234一二三四1234]四半期/i
  24. };
  25. var parseQuarterPatterns = {
  26. any: [/(1|一|1)/i, /(2|二|2)/i, /(3|三|3)/i, /(4|四|4)/i]
  27. };
  28. var matchMonthPatterns = {
  29. narrow: /^([123456789]|1[012])/,
  30. abbreviated: /^([123456789]|1[012])月/i,
  31. wide: /^([123456789]|1[012])月/i
  32. };
  33. var parseMonthPatterns = {
  34. any: [/^1\D/, /^2/, /^3/, /^4/, /^5/, /^6/, /^7/, /^8/, /^9/, /^10/, /^11/, /^12/]
  35. };
  36. var matchDayPatterns = {
  37. narrow: /^[日月火水木金土]/,
  38. short: /^[日月火水木金土]/,
  39. abbreviated: /^[日月火水木金土]/,
  40. wide: /^[日月火水木金土]曜日/
  41. };
  42. var parseDayPatterns = {
  43. any: [/^日/, /^月/, /^火/, /^水/, /^木/, /^金/, /^土/]
  44. };
  45. var matchDayPeriodPatterns = {
  46. any: /^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i
  47. };
  48. var parseDayPeriodPatterns = {
  49. any: {
  50. am: /^(A|午前)/i,
  51. pm: /^(P|午後)/i,
  52. midnight: /^深夜|真夜中/i,
  53. noon: /^正午/i,
  54. morning: /^朝/i,
  55. afternoon: /^午後/i,
  56. evening: /^夜/i,
  57. night: /^深夜/i
  58. }
  59. };
  60. var match = {
  61. ordinalNumber: (0, _index.default)({
  62. matchPattern: matchOrdinalNumberPattern,
  63. parsePattern: parseOrdinalNumberPattern,
  64. valueCallback: function (value) {
  65. return parseInt(value, 10);
  66. }
  67. }),
  68. era: (0, _index2.default)({
  69. matchPatterns: matchEraPatterns,
  70. defaultMatchWidth: 'wide',
  71. parsePatterns: parseEraPatterns,
  72. defaultParseWidth: 'any'
  73. }),
  74. quarter: (0, _index2.default)({
  75. matchPatterns: matchQuarterPatterns,
  76. defaultMatchWidth: 'wide',
  77. parsePatterns: parseQuarterPatterns,
  78. defaultParseWidth: 'any',
  79. valueCallback: function (index) {
  80. return index + 1;
  81. }
  82. }),
  83. month: (0, _index2.default)({
  84. matchPatterns: matchMonthPatterns,
  85. defaultMatchWidth: 'wide',
  86. parsePatterns: parseMonthPatterns,
  87. defaultParseWidth: 'any'
  88. }),
  89. day: (0, _index2.default)({
  90. matchPatterns: matchDayPatterns,
  91. defaultMatchWidth: 'wide',
  92. parsePatterns: parseDayPatterns,
  93. defaultParseWidth: 'any'
  94. }),
  95. dayPeriod: (0, _index2.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;