110 lines
4.6 KiB
JavaScript
110 lines
4.6 KiB
JavaScript
|
"use strict";
|
||
|
|
||
|
Object.defineProperty(exports, "__esModule", {
|
||
|
value: true
|
||
|
});
|
||
|
exports.default = void 0;
|
||
|
|
||
|
var _index = _interopRequireDefault(require("../../../_lib/buildMatchFn/index.js"));
|
||
|
|
||
|
var _index2 = _interopRequireDefault(require("../../../_lib/buildMatchPatternFn/index.js"));
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
var matchOrdinalNumberPattern = /^\d+/i;
|
||
|
var parseOrdinalNumberPattern = /\d+/i;
|
||
|
var matchEraPatterns = {
|
||
|
narrow: /^([bB]|[aA]|คศ)/i,
|
||
|
abbreviated: /^([bB]\.?\s?[cC]\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?|ค\.?ศ\.?)/i,
|
||
|
wide: /^(ก่อนคริสตกาล|คริสต์ศักราช|คริสตกาล)/i
|
||
|
};
|
||
|
var parseEraPatterns = {
|
||
|
any: [/^[bB]/i, /^(^[aA]|ค\.?ศ\.?|คริสตกาล|คริสต์ศักราช|)/i]
|
||
|
};
|
||
|
var matchQuarterPatterns = {
|
||
|
narrow: /^[1234]/i,
|
||
|
abbreviated: /^q[1234]/i,
|
||
|
wide: /^ไตรมาส(ที่)? ?[1234]/i
|
||
|
};
|
||
|
var parseQuarterPatterns = {
|
||
|
any: [/(1|แรก|หนึ่ง)/i, /(2|สอง)/i, /(3|สาม)/i, /(4|สี่)/i]
|
||
|
};
|
||
|
var matchMonthPatterns = {
|
||
|
narrow: /^(ม\.?ค\.?|ก\.?พ\.?|มี\.?ค\.?|เม\.?ย\.?|พ\.?ค\.?|มิ\.?ย\.?|ก\.?ค\.?|ส\.?ค\.?|ก\.?ย\.?|ต\.?ค\.?|พ\.?ย\.?|ธ\.?ค\.?)/i,
|
||
|
abbreviated: /^(ม\.?ค\.?|ก\.?พ\.?|มี\.?ค\.?|เม\.?ย\.?|พ\.?ค\.?|มิ\.?ย\.?|ก\.?ค\.?|ส\.?ค\.?|ก\.?ย\.?|ต\.?ค\.?|พ\.?ย\.?|ธ\.?ค\.?')/i,
|
||
|
wide: /^(มกราคม|กุมภาพันธ์|มีนาคม|เมษายน|พฤษภาคม|มิถุนายน|กรกฎาคม|สิงหาคม|กันยายน|ตุลาคม|พฤศจิกายน|ธันวาคม)/i
|
||
|
};
|
||
|
var parseMonthPatterns = {
|
||
|
wide: [/^มก/i, /^กุม/i, /^มี/i, /^เม/i, /^พฤษ/i, /^มิ/i, /^กรก/i, /^ส/i, /^กัน/i, /^ต/i, /^พฤศ/i, /^ธ/i],
|
||
|
any: [/^ม\.?ค\.?/i, /^ก\.?พ\.?/i, /^มี\.?ค\.?/i, /^เม\.?ย\.?/i, /^พ\.?ค\.?/i, /^มิ\.?ย\.?/i, /^ก\.?ค\.?/i, /^ส\.?ค\.?/i, /^ก\.?ย\.?/i, /^ต\.?ค\.?/i, /^พ\.?ย\.?/i, /^ธ\.?ค\.?/i]
|
||
|
};
|
||
|
var matchDayPatterns = {
|
||
|
narrow: /^(อา\.?|จ\.?|อ\.?|พฤ\.?|พ\.?|ศ\.?|ส\.?)/i,
|
||
|
short: /^(อา\.?|จ\.?|อ\.?|พฤ\.?|พ\.?|ศ\.?|ส\.?)/i,
|
||
|
abbreviated: /^(อา\.?|จ\.?|อ\.?|พฤ\.?|พ\.?|ศ\.?|ส\.?)/i,
|
||
|
wide: /^(อาทิตย์|จันทร์|อังคาร|พุธ|พฤหัสบดี|ศุกร์|เสาร์)/i
|
||
|
};
|
||
|
var parseDayPatterns = {
|
||
|
wide: [/^อา/i, /^จั/i, /^อั/i, /^พุธ/i, /^พฤ/i, /^ศ/i, /^เส/i],
|
||
|
any: [/^อา/i, /^จ/i, /^อ/i, /^พ(?!ฤ)/i, /^พฤ/i, /^ศ/i, /^ส/i]
|
||
|
};
|
||
|
var matchDayPeriodPatterns = {
|
||
|
any: /^(ก่อนเที่ยง|หลังเที่ยง|เที่ยงคืน|เที่ยง|(ตอน.*?)?.*(เที่ยง|เช้า|บ่าย|เย็น|กลางคืน))/i
|
||
|
};
|
||
|
var parseDayPeriodPatterns = {
|
||
|
any: {
|
||
|
am: /^ก่อนเที่ยง/i,
|
||
|
pm: /^หลังเที่ยง/i,
|
||
|
midnight: /^เที่ยงคืน/i,
|
||
|
noon: /^เที่ยง/i,
|
||
|
morning: /เช้า/i,
|
||
|
afternoon: /บ่าย/i,
|
||
|
evening: /เย็น/i,
|
||
|
night: /กลางคืน/i
|
||
|
}
|
||
|
};
|
||
|
var match = {
|
||
|
ordinalNumber: (0, _index2.default)({
|
||
|
matchPattern: matchOrdinalNumberPattern,
|
||
|
parsePattern: parseOrdinalNumberPattern,
|
||
|
valueCallback: function valueCallback(value) {
|
||
|
return parseInt(value, 10);
|
||
|
}
|
||
|
}),
|
||
|
era: (0, _index.default)({
|
||
|
matchPatterns: matchEraPatterns,
|
||
|
defaultMatchWidth: 'wide',
|
||
|
parsePatterns: parseEraPatterns,
|
||
|
defaultParseWidth: 'any'
|
||
|
}),
|
||
|
quarter: (0, _index.default)({
|
||
|
matchPatterns: matchQuarterPatterns,
|
||
|
defaultMatchWidth: 'wide',
|
||
|
parsePatterns: parseQuarterPatterns,
|
||
|
defaultParseWidth: 'any',
|
||
|
valueCallback: function valueCallback(index) {
|
||
|
return index + 1;
|
||
|
}
|
||
|
}),
|
||
|
month: (0, _index.default)({
|
||
|
matchPatterns: matchMonthPatterns,
|
||
|
defaultMatchWidth: 'wide',
|
||
|
parsePatterns: parseMonthPatterns,
|
||
|
defaultParseWidth: 'any'
|
||
|
}),
|
||
|
day: (0, _index.default)({
|
||
|
matchPatterns: matchDayPatterns,
|
||
|
defaultMatchWidth: 'wide',
|
||
|
parsePatterns: parseDayPatterns,
|
||
|
defaultParseWidth: 'any'
|
||
|
}),
|
||
|
dayPeriod: (0, _index.default)({
|
||
|
matchPatterns: matchDayPeriodPatterns,
|
||
|
defaultMatchWidth: 'any',
|
||
|
parsePatterns: parseDayPeriodPatterns,
|
||
|
defaultParseWidth: 'any'
|
||
|
})
|
||
|
};
|
||
|
var _default = match;
|
||
|
exports.default = _default;
|
||
|
module.exports = exports.default;
|