chrono-node 2.3.2 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/common/casualReferences.js +3 -1
- package/dist/common/parsers/AbstractParserWithWordBoundary.js +2 -1
- package/dist/common/refiners/ExtractTimezoneAbbrRefiner.js +5 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/locales/de/constants.js +1 -1
- package/dist/locales/en/constants.js +1 -1
- package/dist/locales/en/parsers/ENRelativeDateFormatParser.js +3 -3
- package/dist/locales/en/parsers/ENTimeUnitAgoFormatParser.js +1 -1
- package/dist/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.js +1 -1
- package/dist/locales/en/parsers/ENTimeUnitLaterFormatParser.js +1 -1
- package/dist/locales/en/parsers/ENTimeUnitWithinFormatParser.js +1 -1
- package/dist/locales/fr/constants.js +1 -1
- package/dist/locales/fr/parsers/FRTimeUnitAgoFormatParser.js +1 -1
- package/dist/locales/fr/parsers/FRTimeUnitRelativeFormatParser.js +1 -1
- package/dist/locales/fr/parsers/FRTimeUnitWithinFormatParser.js +1 -1
- package/dist/locales/nl/parsers/NLRelativeDateFormatParser.js +3 -3
- package/dist/locales/nl/parsers/NLTimeUnitAgoFormatParser.js +1 -1
- package/dist/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.js +1 -1
- package/dist/locales/nl/parsers/NLTimeUnitLaterFormatParser.js +1 -1
- package/dist/locales/nl/parsers/NLTimeUnitWithinFormatParser.js +1 -1
- package/dist/locales/zh/hans/constants.d.ts +27 -0
- package/dist/locales/zh/hans/constants.js +51 -0
- package/dist/locales/zh/hans/index.d.ts +9 -0
- package/dist/locales/zh/hans/index.js +49 -0
- package/dist/locales/zh/hans/parsers/ZHHansCasualDateParser.d.ts +7 -0
- package/dist/locales/zh/hans/parsers/ZHHansCasualDateParser.js +138 -0
- package/dist/locales/zh/hans/parsers/ZHHansDateParser.d.ts +6 -0
- package/dist/locales/zh/hans/parsers/ZHHansDateParser.js +72 -0
- package/dist/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.d.ts +6 -0
- package/dist/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.js +78 -0
- package/dist/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.d.ts +7 -0
- package/dist/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.js +70 -0
- package/dist/locales/zh/hans/parsers/ZHHansTimeExpressionParser.d.ts +6 -0
- package/dist/locales/zh/hans/parsers/ZHHansTimeExpressionParser.js +438 -0
- package/dist/locales/zh/hans/parsers/ZHHansWeekdayParser.d.ts +7 -0
- package/dist/locales/zh/hans/parsers/ZHHansWeekdayParser.js +46 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateRangeRefiner.d.ts +4 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateRangeRefiner.js +12 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateTimeRefiner.d.ts +4 -0
- package/dist/locales/zh/hans/refiners/ZHHansMergeDateTimeRefiner.js +12 -0
- package/dist/locales/zh/hant/constants.d.ts +28 -0
- package/dist/locales/zh/hant/constants.js +52 -0
- package/dist/locales/zh/hant/index.d.ts +9 -0
- package/dist/locales/zh/hant/index.js +49 -0
- package/dist/locales/zh/hant/parsers/ZHHantCasualDateParser.d.ts +7 -0
- package/dist/locales/zh/hant/parsers/ZHHantCasualDateParser.js +138 -0
- package/dist/locales/zh/hant/parsers/ZHHantDateParser.d.ts +6 -0
- package/dist/locales/zh/hant/parsers/ZHHantDateParser.js +64 -0
- package/dist/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.d.ts +6 -0
- package/dist/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.js +78 -0
- package/dist/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.d.ts +7 -0
- package/dist/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.js +70 -0
- package/dist/locales/zh/hant/parsers/ZHHantTimeExpressionParser.d.ts +6 -0
- package/dist/locales/zh/hant/parsers/ZHHantTimeExpressionParser.js +438 -0
- package/dist/locales/zh/hant/parsers/ZHHantWeekdayParser.d.ts +7 -0
- package/dist/locales/zh/hant/parsers/ZHHantWeekdayParser.js +46 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateRangeRefiner.d.ts +4 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateRangeRefiner.js +12 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateTimeRefiner.d.ts +4 -0
- package/dist/locales/zh/hant/refiners/ZHHantMergeDateTimeRefiner.js +12 -0
- package/dist/locales/zh/index.d.ts +2 -0
- package/dist/locales/zh/index.js +16 -0
- package/dist/results.d.ts +2 -2
- package/dist/results.js +18 -12
- package/dist/timezone.d.ts +1 -1
- package/dist/timezone.js +3 -0
- package/dist/utils/dayjs.js +7 -0
- package/package.json +1 -1
- package/src/common/casualReferences.ts +3 -1
- package/src/common/parsers/AbstractParserWithWordBoundary.ts +1 -1
- package/src/common/refiners/ExtractTimezoneAbbrRefiner.ts +8 -0
- package/src/index.ts +2 -1
- package/src/locales/de/constants.ts +1 -1
- package/src/locales/en/constants.ts +1 -1
- package/src/locales/en/parsers/ENMonthNameLittleEndianParser.ts +0 -2
- package/src/locales/en/parsers/ENRelativeDateFormatParser.ts +3 -3
- package/src/locales/en/parsers/ENTimeUnitAgoFormatParser.ts +1 -1
- package/src/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.ts +1 -1
- package/src/locales/en/parsers/ENTimeUnitLaterFormatParser.ts +1 -1
- package/src/locales/en/parsers/ENTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/fr/constants.ts +1 -1
- package/src/locales/fr/parsers/FRTimeUnitAgoFormatParser.ts +1 -1
- package/src/locales/fr/parsers/FRTimeUnitRelativeFormatParser.ts +1 -1
- package/src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/nl/parsers/NLRelativeDateFormatParser.ts +3 -3
- package/src/locales/nl/parsers/NLTimeUnitAgoFormatParser.ts +1 -1
- package/src/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.ts +1 -1
- package/src/locales/nl/parsers/NLTimeUnitLaterFormatParser.ts +1 -1
- package/src/locales/nl/parsers/NLTimeUnitWithinFormatParser.ts +1 -1
- package/src/locales/zh/hans/constants.ts +52 -0
- package/src/locales/zh/hans/index.ts +62 -0
- package/src/locales/zh/hans/parsers/ZHHansCasualDateParser.ts +128 -0
- package/src/locales/zh/hans/parsers/ZHHansDateParser.ts +75 -0
- package/src/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.ts +81 -0
- package/src/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.ts +69 -0
- package/src/locales/zh/hans/parsers/ZHHansTimeExpressionParser.ts +424 -0
- package/src/locales/zh/hans/parsers/ZHHansWeekdayParser.ts +46 -0
- package/src/locales/zh/hans/refiners/ZHHansMergeDateRangeRefiner.ts +7 -0
- package/src/locales/zh/hans/refiners/ZHHansMergeDateTimeRefiner.ts +7 -0
- package/src/locales/zh/hant/constants.ts +53 -0
- package/src/locales/zh/hant/index.ts +63 -0
- package/src/locales/zh/hant/parsers/ZHHantCasualDateParser.ts +128 -0
- package/src/locales/zh/hant/parsers/ZHHantDateParser.ts +68 -0
- package/src/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.ts +81 -0
- package/src/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.ts +69 -0
- package/src/locales/zh/hant/parsers/ZHHantTimeExpressionParser.ts +424 -0
- package/src/locales/zh/hant/parsers/ZHHantWeekdayParser.ts +46 -0
- package/src/locales/zh/hant/refiners/ZHHantMergeDateRangeRefiner.ts +7 -0
- package/src/locales/zh/hant/refiners/ZHHantMergeDateTimeRefiner.ts +7 -0
- package/src/locales/zh/index.ts +2 -0
- package/src/results.ts +22 -12
- package/src/timezone.ts +5 -1
- package/src/utils/dayjs.ts +6 -0
- package/test/en/en_casual.test.ts +11 -0
- package/test/en/en_month.test.ts +13 -0
- package/test/en/en_relative.test.ts +8 -0
- package/test/en/en_time_units_ago.test.ts +16 -0
- package/test/en/en_time_units_later.test.ts +6 -0
- package/test/en/en_timezone_exp.test.ts +85 -10
- package/test/en/negative_cases.test.ts +2 -0
- package/test/test_util.ts +5 -2
- package/test/zh/zh.test.ts +18 -0
- package/test/zh/zh_hans_casual.test.ts +228 -0
- package/test/zh/zh_hans_date.test.ts +102 -0
- package/test/zh/zh_hans_deadline.test.ts +136 -0
- package/test/zh/zh_hans_time_exp.test.ts +182 -0
- package/test/zh/zh_hans_weekday.test.ts +132 -0
- package/test/zh/zh_hant_casual.test.ts +246 -0
- package/test/zh/zh_hant_date.test.ts +102 -0
- package/test/zh/zh_hant_deadline.test.ts +136 -0
- package/test/zh/zh_hant_time_exp.test.ts +182 -0
- package/test/zh/zh_hant_weekday.test.ts +132 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
+
const AbstractParserWithWordBoundary_1 = require("../../../../common/parsers/AbstractParserWithWordBoundary");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const PATTERN = new RegExp("(\\d+|[" +
|
|
10
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
11
|
+
"]+|半|几)(?:\\s*)" +
|
|
12
|
+
"(?:个)?" +
|
|
13
|
+
"(秒(?:钟)?|分钟|小时|钟|日|天|星期|礼拜|月|年)" +
|
|
14
|
+
"(?:(?:之|过)?后|(?:之)?内)", "i");
|
|
15
|
+
const NUMBER_GROUP = 1;
|
|
16
|
+
const UNIT_GROUP = 2;
|
|
17
|
+
class ZHHansDeadlineFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
|
18
|
+
innerPattern() {
|
|
19
|
+
return PATTERN;
|
|
20
|
+
}
|
|
21
|
+
innerExtract(context, match) {
|
|
22
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
23
|
+
let number = parseInt(match[NUMBER_GROUP]);
|
|
24
|
+
if (isNaN(number)) {
|
|
25
|
+
number = constants_1.zhStringToNumber(match[NUMBER_GROUP]);
|
|
26
|
+
}
|
|
27
|
+
if (isNaN(number)) {
|
|
28
|
+
const string = match[NUMBER_GROUP];
|
|
29
|
+
if (string === "几") {
|
|
30
|
+
number = 3;
|
|
31
|
+
}
|
|
32
|
+
else if (string === "半") {
|
|
33
|
+
number = 0.5;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
let date = dayjs_1.default(context.refDate);
|
|
40
|
+
const unit = match[UNIT_GROUP];
|
|
41
|
+
const unitAbbr = unit[0];
|
|
42
|
+
if (unitAbbr.match(/[日天星礼月年]/)) {
|
|
43
|
+
if (unitAbbr == "日" || unitAbbr == "天") {
|
|
44
|
+
date = date.add(number, "d");
|
|
45
|
+
}
|
|
46
|
+
else if (unitAbbr == "星" || unitAbbr == "礼") {
|
|
47
|
+
date = date.add(number * 7, "d");
|
|
48
|
+
}
|
|
49
|
+
else if (unitAbbr == "月") {
|
|
50
|
+
date = date.add(number, "month");
|
|
51
|
+
}
|
|
52
|
+
else if (unitAbbr == "年") {
|
|
53
|
+
date = date.add(number, "year");
|
|
54
|
+
}
|
|
55
|
+
result.start.assign("year", date.year());
|
|
56
|
+
result.start.assign("month", date.month() + 1);
|
|
57
|
+
result.start.assign("day", date.date());
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
if (unitAbbr == "秒") {
|
|
61
|
+
date = date.add(number, "second");
|
|
62
|
+
}
|
|
63
|
+
else if (unitAbbr == "分") {
|
|
64
|
+
date = date.add(number, "minute");
|
|
65
|
+
}
|
|
66
|
+
else if (unitAbbr == "小" || unitAbbr == "钟") {
|
|
67
|
+
date = date.add(number, "hour");
|
|
68
|
+
}
|
|
69
|
+
result.start.imply("year", date.year());
|
|
70
|
+
result.start.imply("month", date.month() + 1);
|
|
71
|
+
result.start.imply("day", date.date());
|
|
72
|
+
result.start.assign("hour", date.hour());
|
|
73
|
+
result.start.assign("minute", date.minute());
|
|
74
|
+
result.start.assign("second", date.second());
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = ZHHansDeadlineFormatParser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../../chrono";
|
|
2
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
+
import { ParsingResult } from "../../../../results";
|
|
4
|
+
export default class ZHHansRelationWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
5
|
+
innerPattern(): RegExp;
|
|
6
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult;
|
|
7
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
+
const AbstractParserWithWordBoundary_1 = require("../../../../common/parsers/AbstractParserWithWordBoundary");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const PATTERN = new RegExp("(?<prefix>上|下|这)(?:个)?(?:星期|礼拜|周)(?<weekday>" + Object.keys(constants_1.WEEKDAY_OFFSET).join("|") + ")");
|
|
10
|
+
class ZHHansRelationWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
|
11
|
+
innerPattern() {
|
|
12
|
+
return PATTERN;
|
|
13
|
+
}
|
|
14
|
+
innerExtract(context, match) {
|
|
15
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
16
|
+
const dayOfWeek = match.groups.weekday;
|
|
17
|
+
const offset = constants_1.WEEKDAY_OFFSET[dayOfWeek];
|
|
18
|
+
if (offset === undefined)
|
|
19
|
+
return null;
|
|
20
|
+
let modifier = null;
|
|
21
|
+
const prefix = match.groups.prefix;
|
|
22
|
+
if (prefix == "上") {
|
|
23
|
+
modifier = "last";
|
|
24
|
+
}
|
|
25
|
+
else if (prefix == "下") {
|
|
26
|
+
modifier = "next";
|
|
27
|
+
}
|
|
28
|
+
else if (prefix == "这") {
|
|
29
|
+
modifier = "this";
|
|
30
|
+
}
|
|
31
|
+
let startMoment = dayjs_1.default(context.refDate);
|
|
32
|
+
let startMomentFixed = false;
|
|
33
|
+
const refOffset = startMoment.day();
|
|
34
|
+
if (modifier == "last" || modifier == "past") {
|
|
35
|
+
startMoment = startMoment.day(offset - 7);
|
|
36
|
+
startMomentFixed = true;
|
|
37
|
+
}
|
|
38
|
+
else if (modifier == "next") {
|
|
39
|
+
startMoment = startMoment.day(offset + 7);
|
|
40
|
+
startMomentFixed = true;
|
|
41
|
+
}
|
|
42
|
+
else if (modifier == "this") {
|
|
43
|
+
startMoment = startMoment.day(offset);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (Math.abs(offset - 7 - refOffset) < Math.abs(offset - refOffset)) {
|
|
47
|
+
startMoment = startMoment.day(offset - 7);
|
|
48
|
+
}
|
|
49
|
+
else if (Math.abs(offset + 7 - refOffset) < Math.abs(offset - refOffset)) {
|
|
50
|
+
startMoment = startMoment.day(offset + 7);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
startMoment = startMoment.day(offset);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
result.start.assign("weekday", offset);
|
|
57
|
+
if (startMomentFixed) {
|
|
58
|
+
result.start.assign("day", startMoment.date());
|
|
59
|
+
result.start.assign("month", startMoment.month() + 1);
|
|
60
|
+
result.start.assign("year", startMoment.year());
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
result.start.imply("day", startMoment.date());
|
|
64
|
+
result.start.imply("month", startMoment.month() + 1);
|
|
65
|
+
result.start.imply("year", startMoment.year());
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.default = ZHHansRelationWeekdayParser;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../../chrono";
|
|
2
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
+
export default class ZHHansTimeExpressionParser extends AbstractParserWithWordBoundaryChecking {
|
|
4
|
+
innerPattern(): RegExp;
|
|
5
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): import("../../../../results").ParsingResult;
|
|
6
|
+
}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
+
const AbstractParserWithWordBoundary_1 = require("../../../../common/parsers/AbstractParserWithWordBoundary");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const FIRST_REG_PATTERN = new RegExp("(?:从|自)?" +
|
|
10
|
+
"(?:" +
|
|
11
|
+
"(今|明|前|大前|后|大后|昨)(早|朝|晚)|" +
|
|
12
|
+
"(上(?:午)|早(?:上)|下(?:午)|晚(?:上)|夜(?:晚)?|中(?:午)|凌(?:晨))|" +
|
|
13
|
+
"(今|明|前|大前|后|大后|昨)(?:日|天)" +
|
|
14
|
+
"(?:[\\s,,]*)" +
|
|
15
|
+
"(?:(上(?:午)|早(?:上)|下(?:午)|晚(?:上)|夜(?:晚)?|中(?:午)|凌(?:晨)))?" +
|
|
16
|
+
")?" +
|
|
17
|
+
"(?:[\\s,,]*)" +
|
|
18
|
+
"(?:(\\d+|[" +
|
|
19
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
20
|
+
"]+)(?:\\s*)(?:点|时|:|:)" +
|
|
21
|
+
"(?:\\s*)" +
|
|
22
|
+
"(\\d+|半|正|整|[" +
|
|
23
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
24
|
+
"]+)?(?:\\s*)(?:分|:|:)?" +
|
|
25
|
+
"(?:\\s*)" +
|
|
26
|
+
"(\\d+|[" +
|
|
27
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
28
|
+
"]+)?(?:\\s*)(?:秒)?)" +
|
|
29
|
+
"(?:\\s*(A.M.|P.M.|AM?|PM?))?", "i");
|
|
30
|
+
const SECOND_REG_PATTERN = new RegExp("(?:^\\s*(?:到|至|\\-|\\–|\\~|\\〜)\\s*)" +
|
|
31
|
+
"(?:" +
|
|
32
|
+
"(今|明|前|大前|后|大后|昨)(早|朝|晚)|" +
|
|
33
|
+
"(上(?:午)|早(?:上)|下(?:午)|晚(?:上)|夜(?:晚)?|中(?:午)|凌(?:晨))|" +
|
|
34
|
+
"(今|明|前|大前|后|大后|昨)(?:日|天)" +
|
|
35
|
+
"(?:[\\s,,]*)" +
|
|
36
|
+
"(?:(上(?:午)|早(?:上)|下(?:午)|晚(?:上)|夜(?:晚)?|中(?:午)|凌(?:晨)))?" +
|
|
37
|
+
")?" +
|
|
38
|
+
"(?:[\\s,,]*)" +
|
|
39
|
+
"(?:(\\d+|[" +
|
|
40
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
41
|
+
"]+)(?:\\s*)(?:点|时|:|:)" +
|
|
42
|
+
"(?:\\s*)" +
|
|
43
|
+
"(\\d+|半|正|整|[" +
|
|
44
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
45
|
+
"]+)?(?:\\s*)(?:分|:|:)?" +
|
|
46
|
+
"(?:\\s*)" +
|
|
47
|
+
"(\\d+|[" +
|
|
48
|
+
Object.keys(constants_1.NUMBER).join("") +
|
|
49
|
+
"]+)?(?:\\s*)(?:秒)?)" +
|
|
50
|
+
"(?:\\s*(A.M.|P.M.|AM?|PM?))?", "i");
|
|
51
|
+
const DAY_GROUP_1 = 1;
|
|
52
|
+
const ZH_AM_PM_HOUR_GROUP_1 = 2;
|
|
53
|
+
const ZH_AM_PM_HOUR_GROUP_2 = 3;
|
|
54
|
+
const DAY_GROUP_3 = 4;
|
|
55
|
+
const ZH_AM_PM_HOUR_GROUP_3 = 5;
|
|
56
|
+
const HOUR_GROUP = 6;
|
|
57
|
+
const MINUTE_GROUP = 7;
|
|
58
|
+
const SECOND_GROUP = 8;
|
|
59
|
+
const AM_PM_HOUR_GROUP = 9;
|
|
60
|
+
class ZHHansTimeExpressionParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
|
61
|
+
innerPattern() {
|
|
62
|
+
return FIRST_REG_PATTERN;
|
|
63
|
+
}
|
|
64
|
+
innerExtract(context, match) {
|
|
65
|
+
if (match.index > 0 && context.text[match.index - 1].match(/\w/)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const refMoment = dayjs_1.default(context.refDate);
|
|
69
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
70
|
+
const startMoment = refMoment.clone();
|
|
71
|
+
if (match[DAY_GROUP_1]) {
|
|
72
|
+
const day1 = match[DAY_GROUP_1];
|
|
73
|
+
if (day1 == "明") {
|
|
74
|
+
if (refMoment.hour() > 1) {
|
|
75
|
+
startMoment.add(1, "day");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else if (day1 == "昨") {
|
|
79
|
+
startMoment.add(-1, "day");
|
|
80
|
+
}
|
|
81
|
+
else if (day1 == "前") {
|
|
82
|
+
startMoment.add(-2, "day");
|
|
83
|
+
}
|
|
84
|
+
else if (day1 == "大前") {
|
|
85
|
+
startMoment.add(-3, "day");
|
|
86
|
+
}
|
|
87
|
+
else if (day1 == "后") {
|
|
88
|
+
startMoment.add(2, "day");
|
|
89
|
+
}
|
|
90
|
+
else if (day1 == "大后") {
|
|
91
|
+
startMoment.add(3, "day");
|
|
92
|
+
}
|
|
93
|
+
result.start.assign("day", startMoment.date());
|
|
94
|
+
result.start.assign("month", startMoment.month() + 1);
|
|
95
|
+
result.start.assign("year", startMoment.year());
|
|
96
|
+
}
|
|
97
|
+
else if (match[DAY_GROUP_3]) {
|
|
98
|
+
const day3 = match[DAY_GROUP_3];
|
|
99
|
+
if (day3 == "明") {
|
|
100
|
+
startMoment.add(1, "day");
|
|
101
|
+
}
|
|
102
|
+
else if (day3 == "昨") {
|
|
103
|
+
startMoment.add(-1, "day");
|
|
104
|
+
}
|
|
105
|
+
else if (day3 == "前") {
|
|
106
|
+
startMoment.add(-2, "day");
|
|
107
|
+
}
|
|
108
|
+
else if (day3 == "大前") {
|
|
109
|
+
startMoment.add(-3, "day");
|
|
110
|
+
}
|
|
111
|
+
else if (day3 == "后") {
|
|
112
|
+
startMoment.add(2, "day");
|
|
113
|
+
}
|
|
114
|
+
else if (day3 == "大后") {
|
|
115
|
+
startMoment.add(3, "day");
|
|
116
|
+
}
|
|
117
|
+
result.start.assign("day", startMoment.date());
|
|
118
|
+
result.start.assign("month", startMoment.month() + 1);
|
|
119
|
+
result.start.assign("year", startMoment.year());
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
result.start.imply("day", startMoment.date());
|
|
123
|
+
result.start.imply("month", startMoment.month() + 1);
|
|
124
|
+
result.start.imply("year", startMoment.year());
|
|
125
|
+
}
|
|
126
|
+
let hour = 0;
|
|
127
|
+
let minute = 0;
|
|
128
|
+
let meridiem = -1;
|
|
129
|
+
if (match[SECOND_GROUP]) {
|
|
130
|
+
let second = parseInt(match[SECOND_GROUP]);
|
|
131
|
+
if (isNaN(second)) {
|
|
132
|
+
second = constants_1.zhStringToNumber(match[SECOND_GROUP]);
|
|
133
|
+
}
|
|
134
|
+
if (second >= 60)
|
|
135
|
+
return null;
|
|
136
|
+
result.start.assign("second", second);
|
|
137
|
+
}
|
|
138
|
+
hour = parseInt(match[HOUR_GROUP]);
|
|
139
|
+
if (isNaN(hour)) {
|
|
140
|
+
hour = constants_1.zhStringToNumber(match[HOUR_GROUP]);
|
|
141
|
+
}
|
|
142
|
+
if (match[MINUTE_GROUP]) {
|
|
143
|
+
if (match[MINUTE_GROUP] == "半") {
|
|
144
|
+
minute = 30;
|
|
145
|
+
}
|
|
146
|
+
else if (match[MINUTE_GROUP] == "正" || match[MINUTE_GROUP] == "整") {
|
|
147
|
+
minute = 0;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
minute = parseInt(match[MINUTE_GROUP]);
|
|
151
|
+
if (isNaN(minute)) {
|
|
152
|
+
minute = constants_1.zhStringToNumber(match[MINUTE_GROUP]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (hour > 100) {
|
|
157
|
+
minute = hour % 100;
|
|
158
|
+
hour = Math.floor(hour / 100);
|
|
159
|
+
}
|
|
160
|
+
if (minute >= 60) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (hour > 24) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (hour >= 12) {
|
|
167
|
+
meridiem = 1;
|
|
168
|
+
}
|
|
169
|
+
if (match[AM_PM_HOUR_GROUP]) {
|
|
170
|
+
if (hour > 12)
|
|
171
|
+
return null;
|
|
172
|
+
const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
|
173
|
+
if (ampm == "a") {
|
|
174
|
+
meridiem = 0;
|
|
175
|
+
if (hour == 12)
|
|
176
|
+
hour = 0;
|
|
177
|
+
}
|
|
178
|
+
if (ampm == "p") {
|
|
179
|
+
meridiem = 1;
|
|
180
|
+
if (hour != 12)
|
|
181
|
+
hour += 12;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else if (match[ZH_AM_PM_HOUR_GROUP_1]) {
|
|
185
|
+
const zhAMPMString1 = match[ZH_AM_PM_HOUR_GROUP_1];
|
|
186
|
+
const zhAMPM1 = zhAMPMString1[0];
|
|
187
|
+
if (zhAMPM1 == "早") {
|
|
188
|
+
meridiem = 0;
|
|
189
|
+
if (hour == 12)
|
|
190
|
+
hour = 0;
|
|
191
|
+
}
|
|
192
|
+
else if (zhAMPM1 == "晚") {
|
|
193
|
+
meridiem = 1;
|
|
194
|
+
if (hour != 12)
|
|
195
|
+
hour += 12;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (match[ZH_AM_PM_HOUR_GROUP_2]) {
|
|
199
|
+
const zhAMPMString2 = match[ZH_AM_PM_HOUR_GROUP_2];
|
|
200
|
+
const zhAMPM2 = zhAMPMString2[0];
|
|
201
|
+
if (zhAMPM2 == "上" || zhAMPM2 == "早" || zhAMPM2 == "凌") {
|
|
202
|
+
meridiem = 0;
|
|
203
|
+
if (hour == 12)
|
|
204
|
+
hour = 0;
|
|
205
|
+
}
|
|
206
|
+
else if (zhAMPM2 == "下" || zhAMPM2 == "晚") {
|
|
207
|
+
meridiem = 1;
|
|
208
|
+
if (hour != 12)
|
|
209
|
+
hour += 12;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else if (match[ZH_AM_PM_HOUR_GROUP_3]) {
|
|
213
|
+
const zhAMPMString3 = match[ZH_AM_PM_HOUR_GROUP_3];
|
|
214
|
+
const zhAMPM3 = zhAMPMString3[0];
|
|
215
|
+
if (zhAMPM3 == "上" || zhAMPM3 == "早" || zhAMPM3 == "凌") {
|
|
216
|
+
meridiem = 0;
|
|
217
|
+
if (hour == 12)
|
|
218
|
+
hour = 0;
|
|
219
|
+
}
|
|
220
|
+
else if (zhAMPM3 == "下" || zhAMPM3 == "晚") {
|
|
221
|
+
meridiem = 1;
|
|
222
|
+
if (hour != 12)
|
|
223
|
+
hour += 12;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
result.start.assign("hour", hour);
|
|
227
|
+
result.start.assign("minute", minute);
|
|
228
|
+
if (meridiem >= 0) {
|
|
229
|
+
result.start.assign("meridiem", meridiem);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
if (hour < 12) {
|
|
233
|
+
result.start.imply("meridiem", 0);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
result.start.imply("meridiem", 1);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
match = SECOND_REG_PATTERN.exec(context.text.substring(result.index + result.text.length));
|
|
240
|
+
if (!match) {
|
|
241
|
+
if (result.text.match(/^\d+$/)) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
const endMoment = startMoment.clone();
|
|
247
|
+
result.end = context.createParsingComponents();
|
|
248
|
+
if (match[DAY_GROUP_1]) {
|
|
249
|
+
const day1 = match[DAY_GROUP_1];
|
|
250
|
+
if (day1 == "明") {
|
|
251
|
+
if (refMoment.hour() > 1) {
|
|
252
|
+
endMoment.add(1, "day");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else if (day1 == "昨") {
|
|
256
|
+
endMoment.add(-1, "day");
|
|
257
|
+
}
|
|
258
|
+
else if (day1 == "前") {
|
|
259
|
+
endMoment.add(-2, "day");
|
|
260
|
+
}
|
|
261
|
+
else if (day1 == "大前") {
|
|
262
|
+
endMoment.add(-3, "day");
|
|
263
|
+
}
|
|
264
|
+
else if (day1 == "后") {
|
|
265
|
+
endMoment.add(2, "day");
|
|
266
|
+
}
|
|
267
|
+
else if (day1 == "大后") {
|
|
268
|
+
endMoment.add(3, "day");
|
|
269
|
+
}
|
|
270
|
+
result.end.assign("day", endMoment.date());
|
|
271
|
+
result.end.assign("month", endMoment.month() + 1);
|
|
272
|
+
result.end.assign("year", endMoment.year());
|
|
273
|
+
}
|
|
274
|
+
else if (match[DAY_GROUP_3]) {
|
|
275
|
+
const day3 = match[DAY_GROUP_3];
|
|
276
|
+
if (day3 == "明") {
|
|
277
|
+
endMoment.add(1, "day");
|
|
278
|
+
}
|
|
279
|
+
else if (day3 == "昨") {
|
|
280
|
+
endMoment.add(-1, "day");
|
|
281
|
+
}
|
|
282
|
+
else if (day3 == "前") {
|
|
283
|
+
endMoment.add(-2, "day");
|
|
284
|
+
}
|
|
285
|
+
else if (day3 == "大前") {
|
|
286
|
+
endMoment.add(-3, "day");
|
|
287
|
+
}
|
|
288
|
+
else if (day3 == "后") {
|
|
289
|
+
endMoment.add(2, "day");
|
|
290
|
+
}
|
|
291
|
+
else if (day3 == "大后") {
|
|
292
|
+
endMoment.add(3, "day");
|
|
293
|
+
}
|
|
294
|
+
result.end.assign("day", endMoment.date());
|
|
295
|
+
result.end.assign("month", endMoment.month() + 1);
|
|
296
|
+
result.end.assign("year", endMoment.year());
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
result.end.imply("day", endMoment.date());
|
|
300
|
+
result.end.imply("month", endMoment.month() + 1);
|
|
301
|
+
result.end.imply("year", endMoment.year());
|
|
302
|
+
}
|
|
303
|
+
hour = 0;
|
|
304
|
+
minute = 0;
|
|
305
|
+
meridiem = -1;
|
|
306
|
+
if (match[SECOND_GROUP]) {
|
|
307
|
+
let second = parseInt(match[SECOND_GROUP]);
|
|
308
|
+
if (isNaN(second)) {
|
|
309
|
+
second = constants_1.zhStringToNumber(match[SECOND_GROUP]);
|
|
310
|
+
}
|
|
311
|
+
if (second >= 60)
|
|
312
|
+
return null;
|
|
313
|
+
result.end.assign("second", second);
|
|
314
|
+
}
|
|
315
|
+
hour = parseInt(match[HOUR_GROUP]);
|
|
316
|
+
if (isNaN(hour)) {
|
|
317
|
+
hour = constants_1.zhStringToNumber(match[HOUR_GROUP]);
|
|
318
|
+
}
|
|
319
|
+
if (match[MINUTE_GROUP]) {
|
|
320
|
+
if (match[MINUTE_GROUP] == "半") {
|
|
321
|
+
minute = 30;
|
|
322
|
+
}
|
|
323
|
+
else if (match[MINUTE_GROUP] == "正" || match[MINUTE_GROUP] == "整") {
|
|
324
|
+
minute = 0;
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
minute = parseInt(match[MINUTE_GROUP]);
|
|
328
|
+
if (isNaN(minute)) {
|
|
329
|
+
minute = constants_1.zhStringToNumber(match[MINUTE_GROUP]);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else if (hour > 100) {
|
|
334
|
+
minute = hour % 100;
|
|
335
|
+
hour = Math.floor(hour / 100);
|
|
336
|
+
}
|
|
337
|
+
if (minute >= 60) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
if (hour > 24) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
if (hour >= 12) {
|
|
344
|
+
meridiem = 1;
|
|
345
|
+
}
|
|
346
|
+
if (match[AM_PM_HOUR_GROUP]) {
|
|
347
|
+
if (hour > 12)
|
|
348
|
+
return null;
|
|
349
|
+
const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
|
350
|
+
if (ampm == "a") {
|
|
351
|
+
meridiem = 0;
|
|
352
|
+
if (hour == 12)
|
|
353
|
+
hour = 0;
|
|
354
|
+
}
|
|
355
|
+
if (ampm == "p") {
|
|
356
|
+
meridiem = 1;
|
|
357
|
+
if (hour != 12)
|
|
358
|
+
hour += 12;
|
|
359
|
+
}
|
|
360
|
+
if (!result.start.isCertain("meridiem")) {
|
|
361
|
+
if (meridiem == 0) {
|
|
362
|
+
result.start.imply("meridiem", 0);
|
|
363
|
+
if (result.start.get("hour") == 12) {
|
|
364
|
+
result.start.assign("hour", 0);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
result.start.imply("meridiem", 1);
|
|
369
|
+
if (result.start.get("hour") != 12) {
|
|
370
|
+
result.start.assign("hour", result.start.get("hour") + 12);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
else if (match[ZH_AM_PM_HOUR_GROUP_1]) {
|
|
376
|
+
const zhAMPMString1 = match[ZH_AM_PM_HOUR_GROUP_1];
|
|
377
|
+
const zhAMPM1 = zhAMPMString1[0];
|
|
378
|
+
if (zhAMPM1 == "早") {
|
|
379
|
+
meridiem = 0;
|
|
380
|
+
if (hour == 12)
|
|
381
|
+
hour = 0;
|
|
382
|
+
}
|
|
383
|
+
else if (zhAMPM1 == "晚") {
|
|
384
|
+
meridiem = 1;
|
|
385
|
+
if (hour != 12)
|
|
386
|
+
hour += 12;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
else if (match[ZH_AM_PM_HOUR_GROUP_2]) {
|
|
390
|
+
const zhAMPMString2 = match[ZH_AM_PM_HOUR_GROUP_2];
|
|
391
|
+
const zhAMPM2 = zhAMPMString2[0];
|
|
392
|
+
if (zhAMPM2 == "上" || zhAMPM2 == "早" || zhAMPM2 == "凌") {
|
|
393
|
+
meridiem = 0;
|
|
394
|
+
if (hour == 12)
|
|
395
|
+
hour = 0;
|
|
396
|
+
}
|
|
397
|
+
else if (zhAMPM2 == "下" || zhAMPM2 == "晚") {
|
|
398
|
+
meridiem = 1;
|
|
399
|
+
if (hour != 12)
|
|
400
|
+
hour += 12;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
else if (match[ZH_AM_PM_HOUR_GROUP_3]) {
|
|
404
|
+
const zhAMPMString3 = match[ZH_AM_PM_HOUR_GROUP_3];
|
|
405
|
+
const zhAMPM3 = zhAMPMString3[0];
|
|
406
|
+
if (zhAMPM3 == "上" || zhAMPM3 == "早" || zhAMPM3 == "凌") {
|
|
407
|
+
meridiem = 0;
|
|
408
|
+
if (hour == 12)
|
|
409
|
+
hour = 0;
|
|
410
|
+
}
|
|
411
|
+
else if (zhAMPM3 == "下" || zhAMPM3 == "晚") {
|
|
412
|
+
meridiem = 1;
|
|
413
|
+
if (hour != 12)
|
|
414
|
+
hour += 12;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
result.text = result.text + match[0];
|
|
418
|
+
result.end.assign("hour", hour);
|
|
419
|
+
result.end.assign("minute", minute);
|
|
420
|
+
if (meridiem >= 0) {
|
|
421
|
+
result.end.assign("meridiem", meridiem);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
const startAtPM = result.start.isCertain("meridiem") && result.start.get("meridiem") == 1;
|
|
425
|
+
if (startAtPM && result.start.get("hour") > hour) {
|
|
426
|
+
result.end.imply("meridiem", 0);
|
|
427
|
+
}
|
|
428
|
+
else if (hour > 12) {
|
|
429
|
+
result.end.imply("meridiem", 1);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (result.end.date().getTime() < result.start.date().getTime()) {
|
|
433
|
+
result.end.imply("day", result.end.get("day") + 1);
|
|
434
|
+
}
|
|
435
|
+
return result;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
exports.default = ZHHansTimeExpressionParser;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../../chrono";
|
|
2
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../../common/parsers/AbstractParserWithWordBoundary";
|
|
3
|
+
import { ParsingResult } from "../../../../results";
|
|
4
|
+
export default class ZHHansWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
5
|
+
innerPattern(): RegExp;
|
|
6
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult;
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
7
|
+
const AbstractParserWithWordBoundary_1 = require("../../../../common/parsers/AbstractParserWithWordBoundary");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const PATTERN = new RegExp("(?:星期|礼拜|周)(?<weekday>" + Object.keys(constants_1.WEEKDAY_OFFSET).join("|") + ")");
|
|
10
|
+
class ZHHansWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
|
11
|
+
innerPattern() {
|
|
12
|
+
return PATTERN;
|
|
13
|
+
}
|
|
14
|
+
innerExtract(context, match) {
|
|
15
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
16
|
+
const dayOfWeek = match.groups.weekday;
|
|
17
|
+
const offset = constants_1.WEEKDAY_OFFSET[dayOfWeek];
|
|
18
|
+
if (offset === undefined)
|
|
19
|
+
return null;
|
|
20
|
+
let startMoment = dayjs_1.default(context.refDate);
|
|
21
|
+
const startMomentFixed = false;
|
|
22
|
+
const refOffset = startMoment.day();
|
|
23
|
+
if (Math.abs(offset - 7 - refOffset) < Math.abs(offset - refOffset)) {
|
|
24
|
+
startMoment = startMoment.day(offset - 7);
|
|
25
|
+
}
|
|
26
|
+
else if (Math.abs(offset + 7 - refOffset) < Math.abs(offset - refOffset)) {
|
|
27
|
+
startMoment = startMoment.day(offset + 7);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
startMoment = startMoment.day(offset);
|
|
31
|
+
}
|
|
32
|
+
result.start.assign("weekday", offset);
|
|
33
|
+
if (startMomentFixed) {
|
|
34
|
+
result.start.assign("day", startMoment.date());
|
|
35
|
+
result.start.assign("month", startMoment.month() + 1);
|
|
36
|
+
result.start.assign("year", startMoment.year());
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
result.start.imply("day", startMoment.date());
|
|
40
|
+
result.start.imply("month", startMoment.month() + 1);
|
|
41
|
+
result.start.imply("year", startMoment.year());
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = ZHHansWeekdayParser;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
|
7
|
+
class ZHHansMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
|
8
|
+
patternBetween() {
|
|
9
|
+
return /^\s*(至|到|-|~|~|-|ー)\s*$/i;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = ZHHansMergeDateRangeRefiner;
|