chrono-node 2.4.2 → 2.5.0
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/.idea/workspace.xml +36 -29
- package/coverage/clover.xml +2036 -1854
- package/coverage/coverage-final.json +146 -137
- package/coverage/lcov-report/index.html +89 -44
- package/coverage/lcov-report/src/calculation/index.html +1 -1
- package/coverage/lcov-report/src/calculation/mergingCalculation.ts.html +35 -35
- package/coverage/lcov-report/src/calculation/years.ts.html +17 -17
- package/coverage/lcov-report/src/chrono.ts.html +57 -57
- package/coverage/lcov-report/src/common/abstractRefiners.ts.html +23 -23
- package/coverage/lcov-report/src/common/calculation/index.html +1 -1
- package/coverage/lcov-report/src/common/calculation/weekdays.ts.html +31 -31
- package/coverage/lcov-report/src/common/casualReferences.ts.html +145 -58
- package/coverage/lcov-report/src/common/index.html +12 -12
- package/coverage/lcov-report/src/common/parsers/AbstractParserWithWordBoundary.ts.html +17 -17
- package/coverage/lcov-report/src/common/parsers/AbstractTimeExpressionParser.ts.html +155 -155
- package/coverage/lcov-report/src/common/parsers/ISOFormatParser.ts.html +14 -14
- package/coverage/lcov-report/src/common/parsers/SlashDateFormatParser.ts.html +36 -36
- package/coverage/lcov-report/src/common/parsers/index.html +1 -1
- package/coverage/lcov-report/src/common/refiners/AbstractMergeDateRangeRefiner.ts.html +18 -18
- package/coverage/lcov-report/src/common/refiners/AbstractMergeDateTimeRefiner.ts.html +9 -9
- package/coverage/lcov-report/src/common/refiners/ExtractTimezoneAbbrRefiner.ts.html +16 -16
- package/coverage/lcov-report/src/common/refiners/ExtractTimezoneOffsetRefiner.ts.html +14 -14
- package/coverage/lcov-report/src/common/refiners/ForwardDateRefiner.ts.html +14 -14
- package/coverage/lcov-report/src/common/refiners/MergeWeekdayComponentRefiner.ts.html +11 -11
- package/coverage/lcov-report/src/common/refiners/OverlapRemovalRefiner.ts.html +16 -16
- package/coverage/lcov-report/src/common/refiners/UnlikelyFormatFilter.ts.html +12 -12
- package/coverage/lcov-report/src/common/refiners/index.html +1 -1
- package/coverage/lcov-report/src/configurations.ts.html +18 -18
- package/coverage/lcov-report/src/debugging.ts.html +4 -4
- package/coverage/lcov-report/src/index.html +7 -7
- package/coverage/lcov-report/src/index.ts.html +35 -32
- package/coverage/lcov-report/src/locales/de/constants.ts.html +15 -15
- package/coverage/lcov-report/src/locales/de/index.html +1 -1
- package/coverage/lcov-report/src/locales/de/index.ts.html +30 -30
- package/coverage/lcov-report/src/locales/de/parsers/DECasualDateParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/de/parsers/DECasualTimeParser.ts.html +7 -7
- package/coverage/lcov-report/src/locales/de/parsers/DEMonthNameLittleEndianParser.ts.html +12 -12
- package/coverage/lcov-report/src/locales/de/parsers/DESpecificTimeExpressionParser.ts.html +9 -9
- package/coverage/lcov-report/src/locales/de/parsers/DETimeExpressionParser.ts.html +3 -3
- package/coverage/lcov-report/src/locales/de/parsers/DETimeUnitRelativeFormatParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/de/parsers/DEWeekdayParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/de/parsers/index.html +1 -1
- package/coverage/lcov-report/src/locales/de/refiners/DEMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/de/refiners/DEMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/de/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/en/constants.ts.html +57 -39
- package/coverage/lcov-report/src/locales/en/index.html +1 -1
- package/coverage/lcov-report/src/locales/en/index.ts.html +36 -36
- package/coverage/lcov-report/src/locales/en/parsers/ENCasualDateParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/en/parsers/ENCasualTimeParser.ts.html +24 -93
- package/coverage/lcov-report/src/locales/en/parsers/ENCasualYearMonthDayParser.ts.html +11 -11
- package/coverage/lcov-report/src/locales/en/parsers/ENMonthNameLittleEndianParser.ts.html +14 -14
- package/coverage/lcov-report/src/locales/en/parsers/ENMonthNameMiddleEndianParser.ts.html +14 -14
- package/coverage/lcov-report/src/locales/en/parsers/ENMonthNameParser.ts.html +12 -12
- package/coverage/lcov-report/src/locales/en/parsers/ENRelativeDateFormatParser.ts.html +11 -11
- package/coverage/lcov-report/src/locales/en/parsers/ENSlashMonthFormatParser.ts.html +7 -7
- package/coverage/lcov-report/src/locales/en/parsers/ENTimeExpressionParser.ts.html +14 -14
- package/coverage/lcov-report/src/locales/en/parsers/ENTimeUnitAgoFormatParser.ts.html +14 -14
- package/coverage/lcov-report/src/locales/en/parsers/ENTimeUnitCasualRelativeFormatParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/en/parsers/ENTimeUnitLaterFormatParser.ts.html +13 -13
- package/coverage/lcov-report/src/locales/en/parsers/ENTimeUnitWithinFormatParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/en/parsers/ENWeekdayParser.ts.html +11 -11
- package/coverage/lcov-report/src/locales/en/parsers/index.html +14 -14
- package/coverage/lcov-report/src/locales/en/refiners/ENMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/en/refiners/ENMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/en/refiners/ENMergeRelativeDateRefiner.ts.html +6 -6
- package/coverage/lcov-report/src/locales/en/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/es/constants.ts.html +340 -0
- package/coverage/lcov-report/src/locales/es/index.html +131 -0
- package/coverage/lcov-report/src/locales/es/index.ts.html +256 -0
- package/coverage/lcov-report/src/locales/es/parsers/ESCasualDateParser.ts.html +178 -0
- package/coverage/lcov-report/src/locales/es/parsers/ESCasualTimeParser.ts.html +226 -0
- package/coverage/lcov-report/src/locales/es/parsers/ESMonthNameLittleEndianParser.ts.html +265 -0
- package/coverage/lcov-report/src/locales/es/parsers/ESTimeExpressionParser.ts.html +145 -0
- package/coverage/lcov-report/src/locales/es/parsers/ESWeekdayParser.ts.html +235 -0
- package/coverage/lcov-report/src/locales/es/parsers/index.html +176 -0
- package/coverage/lcov-report/src/locales/es/refiners/ESMergeDateRangeRefiner.ts.html +130 -0
- package/coverage/lcov-report/src/locales/es/refiners/ESMergeDateTimeRefiner.ts.html +115 -0
- package/coverage/lcov-report/src/locales/es/refiners/index.html +131 -0
- package/coverage/lcov-report/src/locales/fr/constants.ts.html +16 -16
- package/coverage/lcov-report/src/locales/fr/index.html +1 -1
- package/coverage/lcov-report/src/locales/fr/index.ts.html +31 -31
- package/coverage/lcov-report/src/locales/fr/parsers/FRCasualDateParser.ts.html +7 -7
- package/coverage/lcov-report/src/locales/fr/parsers/FRCasualTimeParser.ts.html +4 -4
- package/coverage/lcov-report/src/locales/fr/parsers/FRMonthNameLittleEndianParser.ts.html +13 -13
- package/coverage/lcov-report/src/locales/fr/parsers/FRSpecificTimeExpressionParser.ts.html +9 -9
- package/coverage/lcov-report/src/locales/fr/parsers/FRTimeExpressionParser.ts.html +3 -3
- package/coverage/lcov-report/src/locales/fr/parsers/FRTimeUnitAgoFormatParser.ts.html +7 -7
- package/coverage/lcov-report/src/locales/fr/parsers/FRTimeUnitRelativeFormatParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/fr/parsers/FRTimeUnitWithinFormatParser.ts.html +5 -5
- package/coverage/lcov-report/src/locales/fr/parsers/FRWeekdayParser.ts.html +9 -9
- package/coverage/lcov-report/src/locales/fr/parsers/index.html +1 -1
- package/coverage/lcov-report/src/locales/fr/refiners/FRMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/fr/refiners/FRMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/fr/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/ja/constants.ts.html +2 -2
- package/coverage/lcov-report/src/locales/ja/index.html +1 -1
- package/coverage/lcov-report/src/locales/ja/index.ts.html +15 -15
- package/coverage/lcov-report/src/locales/ja/parsers/JPCasualDateParser.ts.html +6 -6
- package/coverage/lcov-report/src/locales/ja/parsers/JPStandardParser.ts.html +12 -12
- package/coverage/lcov-report/src/locales/ja/parsers/index.html +1 -1
- package/coverage/lcov-report/src/locales/ja/refiners/JPMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/ja/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/nl/constants.ts.html +18 -18
- package/coverage/lcov-report/src/locales/nl/index.html +1 -1
- package/coverage/lcov-report/src/locales/nl/index.ts.html +39 -39
- package/coverage/lcov-report/src/locales/nl/parsers/NLCasualDateParser.ts.html +4 -4
- package/coverage/lcov-report/src/locales/nl/parsers/NLCasualDateTimeParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/nl/parsers/NLCasualTimeParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/nl/parsers/NLCasualYearMonthDayParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/nl/parsers/NLMonthNameMiddleEndianParser.ts.html +13 -13
- package/coverage/lcov-report/src/locales/nl/parsers/NLMonthNameParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/nl/parsers/NLRelativeDateFormatParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/nl/parsers/NLSlashMonthFormatParser.ts.html +6 -6
- package/coverage/lcov-report/src/locales/nl/parsers/NLTimeExpressionParser.ts.html +3 -3
- package/coverage/lcov-report/src/locales/nl/parsers/NLTimeUnitAgoFormatParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/nl/parsers/NLTimeUnitCasualRelativeFormatParser.ts.html +7 -7
- package/coverage/lcov-report/src/locales/nl/parsers/NLTimeUnitLaterFormatParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/nl/parsers/NLTimeUnitWithinFormatParser.ts.html +5 -5
- package/coverage/lcov-report/src/locales/nl/parsers/NLWeekdayParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/nl/parsers/index.html +1 -1
- package/coverage/lcov-report/src/locales/nl/refiners/NLMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/nl/refiners/NLMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/nl/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/pt/constants.ts.html +5 -5
- package/coverage/lcov-report/src/locales/pt/index.html +1 -1
- package/coverage/lcov-report/src/locales/pt/index.ts.html +22 -22
- package/coverage/lcov-report/src/locales/pt/parsers/PTCasualDateParser.ts.html +4 -4
- package/coverage/lcov-report/src/locales/pt/parsers/PTCasualTimeParser.ts.html +6 -6
- package/coverage/lcov-report/src/locales/pt/parsers/PTMonthNameLittleEndianParser.ts.html +12 -12
- package/coverage/lcov-report/src/locales/pt/parsers/PTTimeExpressionParser.ts.html +3 -3
- package/coverage/lcov-report/src/locales/pt/parsers/PTWeekdayParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/pt/parsers/index.html +1 -1
- package/coverage/lcov-report/src/locales/pt/refiners/PTMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/pt/refiners/PTMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/pt/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/ru/constants.ts.html +40 -40
- package/coverage/lcov-report/src/locales/ru/index.html +1 -1
- package/coverage/lcov-report/src/locales/ru/index.ts.html +30 -30
- package/coverage/lcov-report/src/locales/ru/parsers/RUCasualDateParser.ts.html +7 -7
- package/coverage/lcov-report/src/locales/ru/parsers/RUCasualTimeParser.ts.html +9 -9
- package/coverage/lcov-report/src/locales/ru/parsers/RUMonthNameLittleEndianParser.ts.html +14 -14
- package/coverage/lcov-report/src/locales/ru/parsers/RUMonthNameParser.ts.html +11 -11
- package/coverage/lcov-report/src/locales/ru/parsers/RURelativeDateFormatParser.ts.html +11 -11
- package/coverage/lcov-report/src/locales/ru/parsers/RUTimeExpressionParser.ts.html +15 -15
- package/coverage/lcov-report/src/locales/ru/parsers/RUTimeUnitAgoFormatParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts.html +13 -13
- package/coverage/lcov-report/src/locales/ru/parsers/RUTimeUnitWithinFormatParser.ts.html +9 -9
- package/coverage/lcov-report/src/locales/ru/parsers/RUWeekdayParser.ts.html +11 -11
- package/coverage/lcov-report/src/locales/ru/parsers/index.html +1 -1
- package/coverage/lcov-report/src/locales/ru/refiners/RUMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/ru/refiners/RUMergeDateTimeRefiner.ts.html +4 -4
- package/coverage/lcov-report/src/locales/ru/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/zh/hans/constants.ts.html +5 -5
- package/coverage/lcov-report/src/locales/zh/hans/index.html +1 -1
- package/coverage/lcov-report/src/locales/zh/hans/index.ts.html +26 -26
- package/coverage/lcov-report/src/locales/zh/hans/parsers/ZHHansCasualDateParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/zh/hans/parsers/ZHHansDateParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/zh/hans/parsers/ZHHansDeadlineFormatParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/zh/hans/parsers/ZHHansRelationWeekdayParser.ts.html +6 -6
- package/coverage/lcov-report/src/locales/zh/hans/parsers/ZHHansTimeExpressionParser.ts.html +16 -16
- package/coverage/lcov-report/src/locales/zh/hans/parsers/ZHHansWeekdayParser.ts.html +17 -17
- package/coverage/lcov-report/src/locales/zh/hans/parsers/index.html +15 -15
- package/coverage/lcov-report/src/locales/zh/hans/refiners/ZHHansMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/zh/hans/refiners/ZHHansMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/zh/hans/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/zh/hant/constants.ts.html +5 -5
- package/coverage/lcov-report/src/locales/zh/hant/index.html +1 -1
- package/coverage/lcov-report/src/locales/zh/hant/index.ts.html +26 -26
- package/coverage/lcov-report/src/locales/zh/hant/parsers/ZHHantCasualDateParser.ts.html +10 -10
- package/coverage/lcov-report/src/locales/zh/hant/parsers/ZHHantDateParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/zh/hant/parsers/ZHHantDeadlineFormatParser.ts.html +8 -8
- package/coverage/lcov-report/src/locales/zh/hant/parsers/ZHHantRelationWeekdayParser.ts.html +6 -6
- package/coverage/lcov-report/src/locales/zh/hant/parsers/ZHHantTimeExpressionParser.ts.html +16 -16
- package/coverage/lcov-report/src/locales/zh/hant/parsers/ZHHantWeekdayParser.ts.html +17 -17
- package/coverage/lcov-report/src/locales/zh/hant/parsers/index.html +15 -15
- package/coverage/lcov-report/src/locales/zh/hant/refiners/ZHHantMergeDateRangeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/zh/hant/refiners/ZHHantMergeDateTimeRefiner.ts.html +3 -3
- package/coverage/lcov-report/src/locales/zh/hant/refiners/index.html +1 -1
- package/coverage/lcov-report/src/locales/zh/index.html +1 -1
- package/coverage/lcov-report/src/locales/zh/index.ts.html +3 -3
- package/coverage/lcov-report/src/results.ts.html +103 -103
- package/coverage/lcov-report/src/timezone.ts.html +3 -3
- package/coverage/lcov-report/src/utils/dayjs.ts.html +28 -28
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov-report/src/utils/pattern.ts.html +13 -13
- package/coverage/lcov-report/src/utils/timeunits.ts.html +17 -17
- package/coverage/lcov-report/test/index.html +1 -1
- package/coverage/lcov-report/test/test_util.ts.html +34 -34
- package/coverage/lcov.info +2675 -2376
- package/dist/common/casualReferences.d.ts +1 -0
- package/dist/common/casualReferences.js +23 -2
- package/dist/common/casualReferences.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/locales/en/constants.js +6 -0
- package/dist/locales/en/constants.js.map +1 -1
- package/dist/locales/en/parsers/ENCasualTimeParser.js +27 -26
- package/dist/locales/en/parsers/ENCasualTimeParser.js.map +1 -1
- package/dist/locales/es/constants.d.ts +8 -0
- package/dist/locales/es/constants.js +84 -0
- package/dist/locales/es/constants.js.map +1 -0
- package/dist/locales/es/index.d.ts +8 -0
- package/dist/locales/es/index.js +46 -0
- package/dist/locales/es/index.js.map +1 -0
- package/dist/locales/es/parsers/ESCasualDateParser.d.ts +7 -0
- package/dist/locales/es/parsers/ESCasualDateParser.js +45 -0
- package/dist/locales/es/parsers/ESCasualDateParser.js.map +1 -0
- package/dist/locales/es/parsers/ESCasualTimeParser.d.ts +6 -0
- package/dist/locales/es/parsers/ESCasualTimeParser.js +46 -0
- package/dist/locales/es/parsers/ESCasualTimeParser.js.map +1 -0
- package/dist/locales/es/parsers/ESMonthNameLittleEndianParser.d.ts +7 -0
- package/dist/locales/es/parsers/ESMonthNameLittleEndianParser.js +49 -0
- package/dist/locales/es/parsers/ESMonthNameLittleEndianParser.js.map +1 -0
- package/dist/locales/es/parsers/ESTimeExpressionParser.d.ts +5 -0
- package/dist/locales/es/parsers/ESTimeExpressionParser.js +13 -0
- package/dist/locales/es/parsers/ESTimeExpressionParser.js.map +1 -0
- package/dist/locales/es/parsers/ESWeekdayParser.d.ts +7 -0
- package/dist/locales/es/parsers/ESWeekdayParser.js +44 -0
- package/dist/locales/es/parsers/ESWeekdayParser.js.map +1 -0
- package/dist/locales/es/refiners/ESMergeDateRangeRefiner.d.ts +4 -0
- package/dist/locales/es/refiners/ESMergeDateRangeRefiner.js +13 -0
- package/dist/locales/es/refiners/ESMergeDateRangeRefiner.js.map +1 -0
- package/dist/locales/es/refiners/ESMergeDateTimeRefiner.d.ts +4 -0
- package/dist/locales/es/refiners/ESMergeDateTimeRefiner.js +13 -0
- package/dist/locales/es/refiners/ESMergeDateTimeRefiner.js.map +1 -0
- package/dist/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js +1 -1
- package/dist/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.js.map +1 -1
- package/package.json +1 -1
- package/src/common/casualReferences.ts +31 -2
- package/src/index.ts +2 -1
- package/src/locales/en/constants.ts +6 -0
- package/src/locales/en/parsers/ENCasualTimeParser.ts +9 -32
- package/src/locales/es/constants.ts +85 -0
- package/src/locales/es/index.ts +57 -0
- package/src/locales/es/parsers/ESCasualDateParser.ts +31 -0
- package/src/locales/es/parsers/ESCasualTimeParser.ts +47 -0
- package/src/locales/es/parsers/ESMonthNameLittleEndianParser.ts +60 -0
- package/src/locales/es/parsers/ESTimeExpressionParser.ts +20 -0
- package/src/locales/es/parsers/ESWeekdayParser.ts +50 -0
- package/src/locales/es/refiners/ESMergeDateRangeRefiner.ts +15 -0
- package/src/locales/es/refiners/ESMergeDateTimeRefiner.ts +10 -0
- package/src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts +1 -1
- package/src/locales/ru/refiners/RUMergeDateTimeRefiner.ts +1 -1
- package/test/en/en_casual.test.ts +27 -4
- package/test/en/en_time_units_ago.test.ts +17 -0
- package/test/en/en_time_units_later.test.ts +30 -0
- package/test/es/es_casual.test.ts +175 -0
- package/test/es/es_month_name_little_endian.test.ts +217 -0
- package/test/es/es_slash.test.ts +26 -0
- package/test/es/es_time_exp.test.ts +175 -0
- package/test/ru/ru_time_units_casual_relative.test.ts +12 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractTimeExpressionParser_1 = require("../../../common/parsers/AbstractTimeExpressionParser");
|
|
4
|
+
class ESTimeExpressionParser extends AbstractTimeExpressionParser_1.AbstractTimeExpressionParser {
|
|
5
|
+
primaryPrefix() {
|
|
6
|
+
return "(?:(?:aslas|deslas|las?|al?|de|del)\\s*)?";
|
|
7
|
+
}
|
|
8
|
+
followingPhase() {
|
|
9
|
+
return "\\s*(?:\\-|\\–|\\~|\\〜|a(?:l)?|\\?)\\s*";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = ESTimeExpressionParser;
|
|
13
|
+
//# sourceMappingURL=ESTimeExpressionParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ESTimeExpressionParser.js","sourceRoot":"","sources":["../../../../src/locales/es/parsers/ESTimeExpressionParser.ts"],"names":[],"mappings":";;AAAA,uGAAoG;AAEpG,MAAqB,sBAAuB,SAAQ,2DAA4B;IAC5E,aAAa;QACT,OAAO,2CAA2C,CAAC;IACvD,CAAC;IAED,cAAc;QACV,OAAO,yCAAyC,CAAC;IACrD,CAAC;CAUJ;AAjBD,yCAiBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents } from "../../../results";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
export default class ESWeekdayParser extends AbstractParserWithWordBoundaryChecking {
|
|
5
|
+
innerPattern(): RegExp;
|
|
6
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents;
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const pattern_1 = require("../../../utils/pattern");
|
|
5
|
+
const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
|
6
|
+
const weekdays_1 = require("../../../common/calculation/weekdays");
|
|
7
|
+
const PATTERN = new RegExp("(?:(?:\\,|\\(|\\()\\s*)?" +
|
|
8
|
+
"(?:(este|esta|pasado|pr[oó]ximo)\\s*)?" +
|
|
9
|
+
`(${pattern_1.matchAnyPattern(constants_1.WEEKDAY_DICTIONARY)})` +
|
|
10
|
+
"(?:\\s*(?:\\,|\\)|\\)))?" +
|
|
11
|
+
"(?:\\s*(este|esta|pasado|pr[óo]ximo)\\s*semana)?" +
|
|
12
|
+
"(?=\\W|\\d|$)", "i");
|
|
13
|
+
const PREFIX_GROUP = 1;
|
|
14
|
+
const WEEKDAY_GROUP = 2;
|
|
15
|
+
const POSTFIX_GROUP = 3;
|
|
16
|
+
class ESWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
|
17
|
+
innerPattern() {
|
|
18
|
+
return PATTERN;
|
|
19
|
+
}
|
|
20
|
+
innerExtract(context, match) {
|
|
21
|
+
const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
|
22
|
+
const weekday = constants_1.WEEKDAY_DICTIONARY[dayOfWeek];
|
|
23
|
+
if (weekday === undefined) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const prefix = match[PREFIX_GROUP];
|
|
27
|
+
const postfix = match[POSTFIX_GROUP];
|
|
28
|
+
let norm = prefix || postfix || "";
|
|
29
|
+
norm = norm.toLowerCase();
|
|
30
|
+
let modifier = null;
|
|
31
|
+
if (norm == "pasado") {
|
|
32
|
+
modifier = "this";
|
|
33
|
+
}
|
|
34
|
+
else if (norm == "próximo" || norm == "proximo") {
|
|
35
|
+
modifier = "next";
|
|
36
|
+
}
|
|
37
|
+
else if (norm == "este") {
|
|
38
|
+
modifier = "this";
|
|
39
|
+
}
|
|
40
|
+
return weekdays_1.createParsingComponentsAtWeekday(context.reference, weekday, modifier);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = ESWeekdayParser;
|
|
44
|
+
//# sourceMappingURL=ESWeekdayParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ESWeekdayParser.js","sourceRoot":"","sources":["../../../../src/locales/es/parsers/ESWeekdayParser.ts"],"names":[],"mappings":";;AAEA,4CAAkD;AAClD,oDAAyD;AACzD,2GAAgH;AAChH,mEAAwF;AAExF,MAAM,OAAO,GAAG,IAAI,MAAM,CACtB,0BAA0B;IACtB,wCAAwC;IACxC,IAAI,yBAAe,CAAC,8BAAkB,CAAC,GAAG;IAC1C,0BAA0B;IAC1B,kDAAkD;IAClD,eAAe,EACnB,GAAG,CACN,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,MAAqB,eAAgB,SAAQ,uEAAsC;IAC/E,YAAY;QACR,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,YAAY,CAAC,OAAuB,EAAE,KAAuB;QACzD,MAAM,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,WAAW,EAAE,CAAC;QACrD,MAAM,OAAO,GAAG,8BAAkB,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,OAAO,KAAK,SAAS,EAAE;YACvB,OAAO,IAAI,CAAC;SACf;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,IAAI,IAAI,GAAG,MAAM,IAAI,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAE1B,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,IAAI,IAAI,IAAI,QAAQ,EAAE;YAClB,QAAQ,GAAG,MAAM,CAAC;SACrB;aAAM,IAAI,IAAI,IAAI,SAAS,IAAI,IAAI,IAAI,SAAS,EAAE;YAC/C,QAAQ,GAAG,MAAM,CAAC;SACrB;aAAM,IAAI,IAAI,IAAI,MAAM,EAAE;YACvB,QAAQ,GAAG,MAAM,CAAC;SACrB;QAED,OAAO,2CAAgC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClF,CAAC;CACJ;AA5BD,kCA4BC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 ESMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
|
8
|
+
patternBetween() {
|
|
9
|
+
return /^\s*(?:-)\s*$/i;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = ESMergeDateRangeRefiner;
|
|
13
|
+
//# sourceMappingURL=ESMergeDateRangeRefiner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ESMergeDateRangeRefiner.js","sourceRoot":"","sources":["../../../../src/locales/es/refiners/ESMergeDateRangeRefiner.ts"],"names":[],"mappings":";;;;;AAIA,2HAAmG;AAMnG,MAAqB,uBAAwB,SAAQ,uCAA6B;IAC9E,cAAc;QACV,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ;AAJD,0CAIC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 AbstractMergeDateTimeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateTimeRefiner"));
|
|
7
|
+
class ESMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner_1.default {
|
|
8
|
+
patternBetween() {
|
|
9
|
+
return new RegExp("^\\s*(?:,|de|aslas|a)?\\s*$");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = ESMergeDateTimeRefiner;
|
|
13
|
+
//# sourceMappingURL=ESMergeDateTimeRefiner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ESMergeDateTimeRefiner.js","sourceRoot":"","sources":["../../../../src/locales/es/refiners/ESMergeDateTimeRefiner.ts"],"names":[],"mappings":";;;;;AAAA,yHAAiG;AAKjG,MAAqB,sBAAuB,SAAQ,sCAA4B;IAC5E,cAAc;QACV,OAAO,IAAI,MAAM,CAAC,6BAA6B,CAAC,CAAC;IACrD,CAAC;CACJ;AAJD,yCAIC"}
|
|
@@ -4,7 +4,7 @@ const constants_1 = require("../constants");
|
|
|
4
4
|
const results_1 = require("../../../results");
|
|
5
5
|
const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
|
6
6
|
const timeunits_1 = require("../../../utils/timeunits");
|
|
7
|
-
const PATTERN = new RegExp(`(
|
|
7
|
+
const PATTERN = new RegExp(`(эти|последние|прошлые|следующие|после|спустя|через|\\+|-)\\s*(${constants_1.TIME_UNITS_PATTERN})${constants_1.REGEX_PARTS.rightBoundary}`, constants_1.REGEX_PARTS.flags);
|
|
8
8
|
class RUTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
|
9
9
|
patternLeftBoundary() {
|
|
10
10
|
return constants_1.REGEX_PARTS.leftBoundary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RUTimeUnitCasualRelativeFormatParser.js","sourceRoot":"","sources":["../../../../src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts"],"names":[],"mappings":";;AAAA,4CAA+E;AAE/E,8CAAqD;AACrD,2GAAgH;AAChH,wDAA4D;AAE5D,MAAM,OAAO,GAAG,IAAI,MAAM,CACtB,
|
|
1
|
+
{"version":3,"file":"RUTimeUnitCasualRelativeFormatParser.js","sourceRoot":"","sources":["../../../../src/locales/ru/parsers/RUTimeUnitCasualRelativeFormatParser.ts"],"names":[],"mappings":";;AAAA,4CAA+E;AAE/E,8CAAqD;AACrD,2GAAgH;AAChH,wDAA4D;AAE5D,MAAM,OAAO,GAAG,IAAI,MAAM,CACtB,kEAAkE,8BAAkB,IAAI,uBAAW,CAAC,aAAa,EAAE,EACnH,uBAAW,CAAC,KAAK,CACpB,CAAC;AAEF,MAAqB,oCAAqC,SAAQ,uEAAsC;IACpG,mBAAmB;QACf,OAAO,uBAAW,CAAC,YAAY,CAAC;IACpC,CAAC;IAED,YAAY;QACR,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,YAAY,CAAC,OAAuB,EAAE,KAAuB;QACzD,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACtC,IAAI,SAAS,GAAG,0BAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACzC,QAAQ,MAAM,EAAE;YACZ,KAAK,WAAW,CAAC;YACjB,KAAK,SAAS,CAAC;YACf,KAAK,GAAG;gBACJ,SAAS,GAAG,4BAAgB,CAAC,SAAS,CAAC,CAAC;gBACxC,MAAM;SACb;QAED,OAAO,2BAAiB,CAAC,2BAA2B,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACvF,CAAC;CACJ;AAtBD,uDAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { ParsingComponents, ReferenceWithTimezone } from "../results";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
assignSimilarDate,
|
|
5
|
+
assignSimilarTime,
|
|
6
|
+
implySimilarDate,
|
|
7
|
+
implySimilarTime,
|
|
8
|
+
implyTheNextDay,
|
|
9
|
+
} from "../utils/dayjs";
|
|
4
10
|
import { Meridiem } from "../index";
|
|
5
11
|
|
|
6
12
|
export function now(reference: ReferenceWithTimezone): ParsingComponents {
|
|
@@ -88,9 +94,16 @@ export function yesterdayEvening(reference: ReferenceWithTimezone, implyHour = 2
|
|
|
88
94
|
|
|
89
95
|
export function midnight(reference: ReferenceWithTimezone): ParsingComponents {
|
|
90
96
|
const component = new ParsingComponents(reference, {});
|
|
91
|
-
|
|
97
|
+
const targetDate = dayjs(reference.instant);
|
|
98
|
+
if (targetDate.hour() > 2) {
|
|
99
|
+
// Unless it's very early morning (0~2AM), we assume the midnight is the coming midnight.
|
|
100
|
+
// Thus, increasing the day by 1.
|
|
101
|
+
implyTheNextDay(component, targetDate);
|
|
102
|
+
}
|
|
103
|
+
component.assign("hour", 0);
|
|
92
104
|
component.imply("minute", 0);
|
|
93
105
|
component.imply("second", 0);
|
|
106
|
+
component.imply("millisecond", 0);
|
|
94
107
|
return component;
|
|
95
108
|
}
|
|
96
109
|
|
|
@@ -98,6 +111,19 @@ export function morning(reference: ReferenceWithTimezone, implyHour = 6): Parsin
|
|
|
98
111
|
const component = new ParsingComponents(reference, {});
|
|
99
112
|
component.imply("meridiem", Meridiem.AM);
|
|
100
113
|
component.imply("hour", implyHour);
|
|
114
|
+
component.imply("minute", 0);
|
|
115
|
+
component.imply("second", 0);
|
|
116
|
+
component.imply("millisecond", 0);
|
|
117
|
+
return component;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function afternoon(reference: ReferenceWithTimezone, implyHour = 15): ParsingComponents {
|
|
121
|
+
const component = new ParsingComponents(reference, {});
|
|
122
|
+
component.imply("meridiem", Meridiem.PM);
|
|
123
|
+
component.imply("hour", implyHour);
|
|
124
|
+
component.imply("minute", 0);
|
|
125
|
+
component.imply("second", 0);
|
|
126
|
+
component.imply("millisecond", 0);
|
|
101
127
|
return component;
|
|
102
128
|
}
|
|
103
129
|
|
|
@@ -105,5 +131,8 @@ export function noon(reference: ReferenceWithTimezone): ParsingComponents {
|
|
|
105
131
|
const component = new ParsingComponents(reference, {});
|
|
106
132
|
component.imply("meridiem", Meridiem.AM);
|
|
107
133
|
component.imply("hour", 12);
|
|
134
|
+
component.imply("minute", 0);
|
|
135
|
+
component.imply("second", 0);
|
|
136
|
+
component.imply("millisecond", 0);
|
|
108
137
|
return component;
|
|
109
138
|
}
|
package/src/index.ts
CHANGED
|
@@ -117,7 +117,8 @@ import * as pt from "./locales/pt";
|
|
|
117
117
|
import * as nl from "./locales/nl";
|
|
118
118
|
import * as zh from "./locales/zh";
|
|
119
119
|
import * as ru from "./locales/ru";
|
|
120
|
-
|
|
120
|
+
import * as es from "./locales/es";
|
|
121
|
+
export { de, fr, ja, pt, nl, zh, ru, es };
|
|
121
122
|
|
|
122
123
|
/**
|
|
123
124
|
* A shortcut for {@link en | chrono.en.strict}
|
|
@@ -135,9 +135,11 @@ export const ORDINAL_WORD_DICTIONARY: { [word: string]: number } = {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } = {
|
|
138
|
+
s: "second",
|
|
138
139
|
sec: "second",
|
|
139
140
|
second: "second",
|
|
140
141
|
seconds: "second",
|
|
142
|
+
m: "minute",
|
|
141
143
|
min: "minute",
|
|
142
144
|
mins: "minute",
|
|
143
145
|
minute: "minute",
|
|
@@ -147,10 +149,14 @@ export const TIME_UNIT_DICTIONARY: { [word: string]: OpUnitType | QUnitType } =
|
|
|
147
149
|
hrs: "hour",
|
|
148
150
|
hour: "hour",
|
|
149
151
|
hours: "hour",
|
|
152
|
+
d: "d",
|
|
150
153
|
day: "d",
|
|
151
154
|
days: "d",
|
|
155
|
+
w: "w",
|
|
152
156
|
week: "week",
|
|
153
157
|
weeks: "week",
|
|
158
|
+
mo: "month",
|
|
159
|
+
mos: "month",
|
|
154
160
|
month: "month",
|
|
155
161
|
months: "month",
|
|
156
162
|
qtr: "quarter",
|
|
@@ -1,51 +1,28 @@
|
|
|
1
1
|
import { ParsingContext } from "../../../chrono";
|
|
2
|
-
import { Meridiem } from "../../../index";
|
|
3
2
|
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
-
import
|
|
5
|
-
import { implyTheNextDay } from "../../../utils/dayjs";
|
|
6
|
-
import { midnight } from "../../../common/casualReferences";
|
|
3
|
+
import * as casualReferences from "../../../common/casualReferences";
|
|
7
4
|
|
|
8
|
-
const PATTERN = /(?:this)?\s{0,3}(morning|afternoon|evening|night|midnight|noon)(?=\W|$)/i;
|
|
5
|
+
const PATTERN = /(?:this)?\s{0,3}(morning|afternoon|evening|night|midnight|midday|noon)(?=\W|$)/i;
|
|
9
6
|
|
|
10
7
|
export default class ENCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
11
8
|
innerPattern() {
|
|
12
9
|
return PATTERN;
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
16
|
-
const targetDate = dayjs(context.refDate);
|
|
17
|
-
const component = context.createParsingComponents();
|
|
18
|
-
|
|
19
12
|
switch (match[1].toLowerCase()) {
|
|
20
13
|
case "afternoon":
|
|
21
|
-
|
|
22
|
-
component.imply("hour", 15);
|
|
23
|
-
break;
|
|
24
|
-
|
|
14
|
+
return casualReferences.afternoon(context.reference);
|
|
25
15
|
case "evening":
|
|
26
16
|
case "night":
|
|
27
|
-
|
|
28
|
-
component.imply("hour", 20);
|
|
29
|
-
break;
|
|
30
|
-
|
|
17
|
+
return casualReferences.evening(context.reference);
|
|
31
18
|
case "midnight":
|
|
32
|
-
|
|
33
|
-
component.assign("hour", 0);
|
|
34
|
-
component.assign("minute", 0);
|
|
35
|
-
component.assign("second", 0);
|
|
36
|
-
break;
|
|
37
|
-
|
|
19
|
+
return casualReferences.midnight(context.reference);
|
|
38
20
|
case "morning":
|
|
39
|
-
|
|
40
|
-
component.imply("hour", 6);
|
|
41
|
-
break;
|
|
42
|
-
|
|
21
|
+
return casualReferences.morning(context.reference);
|
|
43
22
|
case "noon":
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
break;
|
|
23
|
+
case "midday":
|
|
24
|
+
return casualReferences.noon(context.reference);
|
|
47
25
|
}
|
|
48
|
-
|
|
49
|
-
return component;
|
|
26
|
+
return null;
|
|
50
27
|
}
|
|
51
28
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export const WEEKDAY_DICTIONARY: { [word: string]: number } = {
|
|
2
|
+
"domingo": 0,
|
|
3
|
+
"dom": 0,
|
|
4
|
+
"lunes": 1,
|
|
5
|
+
"lun": 1,
|
|
6
|
+
"martes": 2,
|
|
7
|
+
"mar": 2,
|
|
8
|
+
"miércoles": 3,
|
|
9
|
+
"miercoles": 3,
|
|
10
|
+
"mié": 3,
|
|
11
|
+
"mie": 3,
|
|
12
|
+
"jueves": 4,
|
|
13
|
+
"jue": 4,
|
|
14
|
+
"viernes": 5,
|
|
15
|
+
"vie": 5,
|
|
16
|
+
"sábado": 6,
|
|
17
|
+
"sabado": 6,
|
|
18
|
+
"sáb": 6,
|
|
19
|
+
"sab": 6,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const MONTH_DICTIONARY: { [word: string]: number } = {
|
|
23
|
+
"enero": 1,
|
|
24
|
+
"ene": 1,
|
|
25
|
+
"ene.": 1,
|
|
26
|
+
"febrero": 2,
|
|
27
|
+
"feb": 2,
|
|
28
|
+
"feb.": 2,
|
|
29
|
+
"marzo": 3,
|
|
30
|
+
"mar": 3,
|
|
31
|
+
"mar.": 3,
|
|
32
|
+
"abril": 4,
|
|
33
|
+
"abr": 4,
|
|
34
|
+
"abr.": 4,
|
|
35
|
+
"mayo": 5,
|
|
36
|
+
"may": 5,
|
|
37
|
+
"may.": 5,
|
|
38
|
+
"junio": 6,
|
|
39
|
+
"jun": 6,
|
|
40
|
+
"jun.": 6,
|
|
41
|
+
"julio": 7,
|
|
42
|
+
"jul": 7,
|
|
43
|
+
"jul.": 7,
|
|
44
|
+
"agosto": 8,
|
|
45
|
+
"ago": 8,
|
|
46
|
+
"ago.": 8,
|
|
47
|
+
"septiembre": 9,
|
|
48
|
+
"setiembre": 9,
|
|
49
|
+
"sep": 9,
|
|
50
|
+
"sep.": 9,
|
|
51
|
+
"octubre": 10,
|
|
52
|
+
"oct": 10,
|
|
53
|
+
"oct.": 10,
|
|
54
|
+
"noviembre": 11,
|
|
55
|
+
"nov": 11,
|
|
56
|
+
"nov.": 11,
|
|
57
|
+
"diciembre": 12,
|
|
58
|
+
"dic": 12,
|
|
59
|
+
"dic.": 12,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//-----------------------------
|
|
63
|
+
// 88 p. Chr. n.
|
|
64
|
+
// 234 AC
|
|
65
|
+
export const YEAR_PATTERN = "[0-9]{1,4}(?![^\\s]\\d)(?:\\s*[a|d]\\.?\\s*c\\.?|\\s*a\\.?\\s*d\\.?)?";
|
|
66
|
+
export function parseYear(match: string): number {
|
|
67
|
+
if (match.match(/^[0-9]{1,4}$/)) {
|
|
68
|
+
let yearNumber = parseInt(match);
|
|
69
|
+
if (yearNumber < 100) {
|
|
70
|
+
if (yearNumber > 50) {
|
|
71
|
+
yearNumber = yearNumber + 1900;
|
|
72
|
+
} else {
|
|
73
|
+
yearNumber = yearNumber + 2000;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return yearNumber;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (match.match(/a\.?\s*c\.?/i)) {
|
|
80
|
+
match = match.replace(/a\.?\s*c\.?/i, "");
|
|
81
|
+
return -parseInt(match);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return parseInt(match);
|
|
85
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chrono components for Portuguese support (*parsers*, *refiners*, and *configuration*)
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { includeCommonConfiguration } from "../../configurations";
|
|
8
|
+
import { ParsedResult, ParsingOption } from "../../index";
|
|
9
|
+
import { Chrono, Configuration } from "../../chrono";
|
|
10
|
+
import SlashDateFormatParser from "../../common/parsers/SlashDateFormatParser";
|
|
11
|
+
import ESWeekdayParser from "./parsers/ESWeekdayParser";
|
|
12
|
+
import ESTimeExpressionParser from "./parsers/ESTimeExpressionParser";
|
|
13
|
+
import ESMergeDateTimeRefiner from "./refiners/ESMergeDateTimeRefiner";
|
|
14
|
+
import ESMergeDateRangeRefiner from "./refiners/ESMergeDateRangeRefiner";
|
|
15
|
+
import ESMonthNameLittleEndianParser from "./parsers/ESMonthNameLittleEndianParser";
|
|
16
|
+
import ESCasualDateParser from "./parsers/ESCasualDateParser";
|
|
17
|
+
import ESCasualTimeParser from "./parsers/ESCasualTimeParser";
|
|
18
|
+
|
|
19
|
+
// Shortcuts
|
|
20
|
+
export const casual = new Chrono(createCasualConfiguration());
|
|
21
|
+
export const strict = new Chrono(createConfiguration(true));
|
|
22
|
+
|
|
23
|
+
export function parse(text: string, ref?: Date, option?: ParsingOption): ParsedResult[] {
|
|
24
|
+
return casual.parse(text, ref, option);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parseDate(text: string, ref?: Date, option?: ParsingOption): Date {
|
|
28
|
+
return casual.parseDate(text, ref, option);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @ignore (to be documented later)
|
|
33
|
+
*/
|
|
34
|
+
export function createCasualConfiguration(littleEndian = true): Configuration {
|
|
35
|
+
const option = createConfiguration(false, littleEndian);
|
|
36
|
+
option.parsers.push(new ESCasualDateParser());
|
|
37
|
+
option.parsers.push(new ESCasualTimeParser());
|
|
38
|
+
return option;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @ignore (to be documented later)
|
|
43
|
+
*/
|
|
44
|
+
export function createConfiguration(strictMode = true, littleEndian = true): Configuration {
|
|
45
|
+
return includeCommonConfiguration(
|
|
46
|
+
{
|
|
47
|
+
parsers: [
|
|
48
|
+
new SlashDateFormatParser(littleEndian),
|
|
49
|
+
new ESWeekdayParser(),
|
|
50
|
+
new ESTimeExpressionParser(),
|
|
51
|
+
new ESMonthNameLittleEndianParser(),
|
|
52
|
+
],
|
|
53
|
+
refiners: [new ESMergeDateTimeRefiner(), new ESMergeDateRangeRefiner()],
|
|
54
|
+
},
|
|
55
|
+
strictMode
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingComponents, ParsingResult } from "../../../results";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
import * as references from "../../../common/casualReferences";
|
|
5
|
+
|
|
6
|
+
export default class ESCasualDateParser extends AbstractParserWithWordBoundaryChecking {
|
|
7
|
+
innerPattern(context: ParsingContext): RegExp {
|
|
8
|
+
return /(ahora|hoy|mañana|ayer)(?=\W|$)/i;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | ParsingResult {
|
|
12
|
+
const lowerText = match[0].toLowerCase();
|
|
13
|
+
const component = context.createParsingComponents();
|
|
14
|
+
|
|
15
|
+
switch (lowerText) {
|
|
16
|
+
case "ahora":
|
|
17
|
+
return references.now(context.reference);
|
|
18
|
+
|
|
19
|
+
case "hoy":
|
|
20
|
+
return references.today(context.reference);
|
|
21
|
+
|
|
22
|
+
case "mañana":
|
|
23
|
+
return references.tomorrow(context.reference);
|
|
24
|
+
|
|
25
|
+
case "ayer":
|
|
26
|
+
return references.yesterday(context.reference);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return component;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { Meridiem } from "../../../index";
|
|
3
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
4
|
+
import { assignTheNextDay } from "../../../utils/dayjs";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
|
|
7
|
+
export default class ESCasualTimeParser extends AbstractParserWithWordBoundaryChecking {
|
|
8
|
+
innerPattern() {
|
|
9
|
+
return /(?:esta\s*)?(mañana|tarde|medianoche|mediodia|mediodía|noche)(?=\W|$)/i;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray) {
|
|
13
|
+
const targetDate = dayjs(context.refDate);
|
|
14
|
+
const component = context.createParsingComponents();
|
|
15
|
+
switch (match[1].toLowerCase()) {
|
|
16
|
+
case "tarde":
|
|
17
|
+
component.imply("meridiem", Meridiem.PM);
|
|
18
|
+
component.imply("hour", 15);
|
|
19
|
+
break;
|
|
20
|
+
|
|
21
|
+
case "noche":
|
|
22
|
+
component.imply("meridiem", Meridiem.PM);
|
|
23
|
+
component.imply("hour", 22);
|
|
24
|
+
break;
|
|
25
|
+
|
|
26
|
+
case "mañana":
|
|
27
|
+
component.imply("meridiem", Meridiem.AM);
|
|
28
|
+
component.imply("hour", 6);
|
|
29
|
+
break;
|
|
30
|
+
|
|
31
|
+
case "medianoche":
|
|
32
|
+
assignTheNextDay(component, targetDate);
|
|
33
|
+
component.imply("hour", 0);
|
|
34
|
+
component.imply("minute", 0);
|
|
35
|
+
component.imply("second", 0);
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case "mediodia":
|
|
39
|
+
case "mediodía":
|
|
40
|
+
component.imply("meridiem", Meridiem.AM);
|
|
41
|
+
component.imply("hour", 12);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return component;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ParsingContext } from "../../../chrono";
|
|
2
|
+
import { ParsingResult } from "../../../results";
|
|
3
|
+
import { findYearClosestToRef } from "../../../calculation/years";
|
|
4
|
+
import { MONTH_DICTIONARY } from "../constants";
|
|
5
|
+
import { YEAR_PATTERN, parseYear } from "../constants";
|
|
6
|
+
import { matchAnyPattern } from "../../../utils/pattern";
|
|
7
|
+
import { AbstractParserWithWordBoundaryChecking } from "../../../common/parsers/AbstractParserWithWordBoundary";
|
|
8
|
+
|
|
9
|
+
const PATTERN = new RegExp(
|
|
10
|
+
`([0-9]{1,2})(?:º|ª|°)?` +
|
|
11
|
+
"(?:\\s*(?:desde|de|\\-|\\–|ao?|\\s)\\s*([0-9]{1,2})(?:º|ª|°)?)?\\s*(?:de)?\\s*" +
|
|
12
|
+
`(?:-|/|\\s*(?:de|,)?\\s*)` +
|
|
13
|
+
`(${matchAnyPattern(MONTH_DICTIONARY)})` +
|
|
14
|
+
`(?:\\s*(?:de|,)?\\s*(${YEAR_PATTERN}))?` +
|
|
15
|
+
`(?=\\W|$)`,
|
|
16
|
+
"i"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const DATE_GROUP = 1;
|
|
20
|
+
const DATE_TO_GROUP = 2;
|
|
21
|
+
const MONTH_NAME_GROUP = 3;
|
|
22
|
+
const YEAR_GROUP = 4;
|
|
23
|
+
|
|
24
|
+
export default class ESMonthNameLittleEndianParser extends AbstractParserWithWordBoundaryChecking {
|
|
25
|
+
innerPattern(): RegExp {
|
|
26
|
+
return PATTERN;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
innerExtract(context: ParsingContext, match: RegExpMatchArray): ParsingResult {
|
|
30
|
+
const result = context.createParsingResult(match.index, match[0]);
|
|
31
|
+
|
|
32
|
+
const month = MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
|
33
|
+
const day = parseInt(match[DATE_GROUP]);
|
|
34
|
+
if (day > 31) {
|
|
35
|
+
// e.g. "[96 Aug]" => "9[6 Aug]", we need to shift away from the next number
|
|
36
|
+
match.index = match.index + match[DATE_GROUP].length;
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
result.start.assign("month", month);
|
|
41
|
+
result.start.assign("day", day);
|
|
42
|
+
|
|
43
|
+
if (match[YEAR_GROUP]) {
|
|
44
|
+
const yearNumber = parseYear(match[YEAR_GROUP]);
|
|
45
|
+
result.start.assign("year", yearNumber);
|
|
46
|
+
} else {
|
|
47
|
+
const year = findYearClosestToRef(context.refDate, day, month);
|
|
48
|
+
result.start.imply("year", year);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (match[DATE_TO_GROUP]) {
|
|
52
|
+
const endDate = parseInt(match[DATE_TO_GROUP]);
|
|
53
|
+
|
|
54
|
+
result.end = result.start.clone();
|
|
55
|
+
result.end.assign("day", endDate);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractTimeExpressionParser } from "../../../common/parsers/AbstractTimeExpressionParser";
|
|
2
|
+
|
|
3
|
+
export default class ESTimeExpressionParser extends AbstractTimeExpressionParser {
|
|
4
|
+
primaryPrefix(): string {
|
|
5
|
+
return "(?:(?:aslas|deslas|las?|al?|de|del)\\s*)?";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
followingPhase(): string {
|
|
9
|
+
return "\\s*(?:\\-|\\–|\\~|\\〜|a(?:l)?|\\?)\\s*";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// extractPrimaryTimeComponents(context: ParsingContext, match: RegExpMatchArray): ParsingComponents | null {
|
|
13
|
+
// // This looks more like a year e.g. 2020
|
|
14
|
+
// // if (match[0].match(/^\s*\d{4}\s*$/)) {
|
|
15
|
+
// // return null;
|
|
16
|
+
// // }
|
|
17
|
+
//
|
|
18
|
+
// return super.extractPrimaryTimeComponents(context, match);
|
|
19
|
+
// }
|
|
20
|
+
}
|