index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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: /^(tcn|scn)/i,
  13. abbreviated: /^(trước CN|sau CN)/i,
  14. wide: /^(trước Công Nguyên|sau Công Nguyên)/i
  15. };
  16. var parseEraPatterns = {
  17. any: [/^t/i, /^s/i]
  18. };
  19. var matchQuarterPatterns = {
  20. narrow: /^([1234]|i{1,3}v?)/i,
  21. abbreviated: /^q([1234]|i{1,3}v?)/i,
  22. wide: /^quý ([1234]|i{1,3}v?)/i
  23. };
  24. var parseQuarterPatterns = {
  25. any: [/(1|i)$/i, /(2|ii)$/i, /(3|iii)$/i, /(4|iv)$/i]
  26. };
  27. var matchMonthPatterns = {
  28. // month number may contain leading 0, 'thg' prefix may have space, underscore or empty before number
  29. // note the order of '1' since it is a sub-string of '10', so must be lower priority
  30. narrow: /^(0?[2-9]|10|11|12|0?1)/i,
  31. // note the order of 'thg 1' since it is sub-string of 'thg 10', so must be lower priority
  32. abbreviated: /^thg[ _]?(0?[1-9](?!\d)|10|11|12)/i,
  33. // note the order of 'Mười' since it is sub-string of Mười Một, so must be lower priority
  34. wide: /^tháng ?(Một|Hai|Ba|Tư|Năm|Sáu|Bảy|Tám|Chín|Mười|Mười ?Một|Mười ?Hai|0?[1-9](?!\d)|10|11|12)/i
  35. };
  36. var parseMonthPatterns = {
  37. narrow: [/0?1$/i, /0?2/i, /3/, /4/, /5/, /6/, /7/, /8/, /9/, /10/, /11/, /12/],
  38. abbreviated: [/^thg[ _]?0?1(?!\d)/i, /^thg[ _]?0?2/i, /^thg[ _]?0?3/i, /^thg[ _]?0?4/i, /^thg[ _]?0?5/i, /^thg[ _]?0?6/i, /^thg[ _]?0?7/i, /^thg[ _]?0?8/i, /^thg[ _]?0?9/i, /^thg[ _]?10/i, /^thg[ _]?11/i, /^thg[ _]?12/i],
  39. wide: [/^tháng ?(Một|0?1(?!\d))/i, /^tháng ?(Hai|0?2)/i, /^tháng ?(Ba|0?3)/i, /^tháng ?(Tư|0?4)/i, /^tháng ?(Năm|0?5)/i, /^tháng ?(Sáu|0?6)/i, /^tháng ?(Bảy|0?7)/i, /^tháng ?(Tám|0?8)/i, /^tháng ?(Chín|0?9)/i, /^tháng ?(Mười|10)/i, /^tháng ?(Mười ?Một|11)/i, /^tháng ?(Mười ?Hai|12)/i]
  40. };
  41. var matchDayPatterns = {
  42. narrow: /^(CN|T2|T3|T4|T5|T6|T7)/i,
  43. short: /^(CN|Th ?2|Th ?3|Th ?4|Th ?5|Th ?6|Th ?7)/i,
  44. abbreviated: /^(CN|Th ?2|Th ?3|Th ?4|Th ?5|Th ?6|Th ?7)/i,
  45. wide: /^(Chủ ?Nhật|Chúa ?Nhật|thứ ?Hai|thứ ?Ba|thứ ?Tư|thứ ?Năm|thứ ?Sáu|thứ ?Bảy)/i
  46. };
  47. var parseDayPatterns = {
  48. narrow: [/CN/i, /2/i, /3/i, /4/i, /5/i, /6/i, /7/i],
  49. short: [/CN/i, /2/i, /3/i, /4/i, /5/i, /6/i, /7/i],
  50. abbreviated: [/CN/i, /2/i, /3/i, /4/i, /5/i, /6/i, /7/i],
  51. wide: [/(Chủ|Chúa) ?Nhật/i, /Hai/i, /Ba/i, /Tư/i, /Năm/i, /Sáu/i, /Bảy/i]
  52. };
  53. var matchDayPeriodPatterns = {
  54. narrow: /^(a|p|nửa đêm|trưa|(giờ) (sáng|chiều|tối|đêm))/i,
  55. abbreviated: /^(am|pm|nửa đêm|trưa|(giờ) (sáng|chiều|tối|đêm))/i,
  56. wide: /^(ch[^i]*|sa|nửa đêm|trưa|(giờ) (sáng|chiều|tối|đêm))/i
  57. };
  58. var parseDayPeriodPatterns = {
  59. any: {
  60. am: /^(a|sa)/i,
  61. pm: /^(p|ch[^i]*)/i,
  62. midnight: /nửa đêm/i,
  63. noon: /trưa/i,
  64. morning: /sáng/i,
  65. afternoon: /chiều/i,
  66. evening: /tối/i,
  67. night: /^đêm/i
  68. }
  69. };
  70. var match = {
  71. ordinalNumber: (0, _index.default)({
  72. matchPattern: matchOrdinalNumberPattern,
  73. parsePattern: parseOrdinalNumberPattern,
  74. valueCallback: function (value) {
  75. return parseInt(value, 10);
  76. }
  77. }),
  78. era: (0, _index2.default)({
  79. matchPatterns: matchEraPatterns,
  80. defaultMatchWidth: 'wide',
  81. parsePatterns: parseEraPatterns,
  82. defaultParseWidth: 'any'
  83. }),
  84. quarter: (0, _index2.default)({
  85. matchPatterns: matchQuarterPatterns,
  86. defaultMatchWidth: 'wide',
  87. parsePatterns: parseQuarterPatterns,
  88. defaultParseWidth: 'any',
  89. valueCallback: function (index) {
  90. return index + 1;
  91. }
  92. }),
  93. month: (0, _index2.default)({
  94. matchPatterns: matchMonthPatterns,
  95. defaultMatchWidth: 'wide',
  96. parsePatterns: parseMonthPatterns,
  97. defaultParseWidth: 'any'
  98. }),
  99. day: (0, _index2.default)({
  100. matchPatterns: matchDayPatterns,
  101. defaultMatchWidth: 'wide',
  102. parsePatterns: parseDayPatterns,
  103. defaultParseWidth: 'any'
  104. }),
  105. dayPeriod: (0, _index2.default)({
  106. matchPatterns: matchDayPeriodPatterns,
  107. defaultMatchWidth: 'any',
  108. parsePatterns: parseDayPeriodPatterns,
  109. defaultParseWidth: 'any'
  110. })
  111. };
  112. var _default = match;
  113. exports.default = _default;
  114. module.exports = exports.default;