index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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+)(af|ail|ydd|ed|fed|eg|ain)?/i;
  10. var parseOrdinalNumberPattern = /\d+/i;
  11. var matchEraPatterns = {
  12. narrow: /^(c|o)/i,
  13. abbreviated: /^(c\.?\s?c\.?|o\.?\s?c\.?)/i,
  14. wide: /^(cyn christ|ar ôl crist|ar ol crist)/i
  15. };
  16. var parseEraPatterns = {
  17. wide: [/^c/i, /^(ar ôl crist|ar ol crist)/i],
  18. any: [/^c/i, /^o/i]
  19. };
  20. var matchQuarterPatterns = {
  21. narrow: /^[1234]/i,
  22. abbreviated: /^ch[1234]/i,
  23. wide: /^(chwarter 1af)|([234](ail|ydd)? chwarter)/i
  24. };
  25. var parseQuarterPatterns = {
  26. any: [/1/i, /2/i, /3/i, /4/i]
  27. };
  28. var matchMonthPatterns = {
  29. narrow: /^(i|ch|m|e|g|a|h|t|rh)/i,
  30. abbreviated: /^(ion|chwe|maw|ebr|mai|meh|gor|aws|med|hyd|tach|rhag)/i,
  31. wide: /^(ionawr|chwefror|mawrth|ebrill|mai|mehefin|gorffennaf|awst|medi|hydref|tachwedd|rhagfyr)/i
  32. };
  33. var parseMonthPatterns = {
  34. narrow: [/^i/i, /^ch/i, /^m/i, /^e/i, /^m/i, /^m/i, /^g/i, /^a/i, /^m/i, /^h/i, /^t/i, /^rh/i],
  35. any: [/^io/i, /^ch/i, /^maw/i, /^e/i, /^mai/i, /^meh/i, /^g/i, /^a/i, /^med/i, /^h/i, /^t/i, /^rh/i]
  36. };
  37. var matchDayPatterns = {
  38. narrow: /^(s|ll|m|i|g)/i,
  39. short: /^(su|ll|ma|me|ia|gw|sa)/i,
  40. abbreviated: /^(sul|llun|maw|mer|iau|gwe|sad)/i,
  41. wide: /^dydd (sul|llun|mawrth|mercher|iau|gwener|sadwrn)/i
  42. };
  43. var parseDayPatterns = {
  44. narrow: [/^s/i, /^ll/i, /^m/i, /^m/i, /^i/i, /^g/i, /^s/i],
  45. wide: [/^dydd su/i, /^dydd ll/i, /^dydd ma/i, /^dydd me/i, /^dydd i/i, /^dydd g/i, /^dydd sa/i],
  46. any: [/^su/i, /^ll/i, /^ma/i, /^me/i, /^i/i, /^g/i, /^sa/i]
  47. };
  48. var matchDayPeriodPatterns = {
  49. narrow: /^(b|h|hn|hd|(yn y|y|yr|gyda'r) (bore|prynhawn|nos|hwyr))/i,
  50. any: /^(y\.?\s?[bh]\.?|hanner nos|hanner dydd|(yn y|y|yr|gyda'r) (bore|prynhawn|nos|hwyr))/i
  51. };
  52. var parseDayPeriodPatterns = {
  53. any: {
  54. am: /^b|(y\.?\s?b\.?)/i,
  55. pm: /^h|(y\.?\s?h\.?)|(yr hwyr)/i,
  56. midnight: /^hn|hanner nos/i,
  57. noon: /^hd|hanner dydd/i,
  58. morning: /bore/i,
  59. afternoon: /prynhawn/i,
  60. evening: /^gyda'r nos$/i,
  61. night: /blah/i
  62. }
  63. };
  64. var match = {
  65. ordinalNumber: (0, _index2.default)({
  66. matchPattern: matchOrdinalNumberPattern,
  67. parsePattern: parseOrdinalNumberPattern,
  68. valueCallback: function valueCallback(value) {
  69. return parseInt(value, 10);
  70. }
  71. }),
  72. era: (0, _index.default)({
  73. matchPatterns: matchEraPatterns,
  74. defaultMatchWidth: 'wide',
  75. parsePatterns: parseEraPatterns,
  76. defaultParseWidth: 'any'
  77. }),
  78. quarter: (0, _index.default)({
  79. matchPatterns: matchQuarterPatterns,
  80. defaultMatchWidth: 'wide',
  81. parsePatterns: parseQuarterPatterns,
  82. defaultParseWidth: 'any',
  83. valueCallback: function valueCallback(index) {
  84. return index + 1;
  85. }
  86. }),
  87. month: (0, _index.default)({
  88. matchPatterns: matchMonthPatterns,
  89. defaultMatchWidth: 'wide',
  90. parsePatterns: parseMonthPatterns,
  91. defaultParseWidth: 'any'
  92. }),
  93. day: (0, _index.default)({
  94. matchPatterns: matchDayPatterns,
  95. defaultMatchWidth: 'wide',
  96. parsePatterns: parseDayPatterns,
  97. defaultParseWidth: 'any'
  98. }),
  99. dayPeriod: (0, _index.default)({
  100. matchPatterns: matchDayPeriodPatterns,
  101. defaultMatchWidth: 'any',
  102. parsePatterns: parseDayPeriodPatterns,
  103. defaultParseWidth: 'any'
  104. })
  105. };
  106. var _default = match;
  107. exports.default = _default;
  108. module.exports = exports.default;