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,175 @@
|
|
|
1
|
+
import * as chrono from "../../src";
|
|
2
|
+
import { testSingleCase } from "../test_util";
|
|
3
|
+
|
|
4
|
+
test("Test - Single Expression", function () {
|
|
5
|
+
testSingleCase(chrono.es, "Estaremos a las 6.13 AM", new Date(2012, 7, 10), (result) => {
|
|
6
|
+
expect(result.index).toBe(12);
|
|
7
|
+
expect(result.text).toBe("las 6.13 AM");
|
|
8
|
+
|
|
9
|
+
expect(result.start).not.toBeNull();
|
|
10
|
+
expect(result.start.get("hour")).toBe(6);
|
|
11
|
+
expect(result.start.get("minute")).toBe(13);
|
|
12
|
+
|
|
13
|
+
expect(result.start).toBeDate(new Date(2012, 7, 10, 6, 13));
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test("Test - Range Expression", function () {
|
|
18
|
+
testSingleCase(chrono.es, "8:10 - 12.32", new Date(2012, 7, 10), (result) => {
|
|
19
|
+
expect(result.index).toBe(0);
|
|
20
|
+
expect(result.text).toBe("8:10 - 12.32");
|
|
21
|
+
|
|
22
|
+
expect(result.start).not.toBeNull();
|
|
23
|
+
expect(result.start.get("hour")).toBe(8);
|
|
24
|
+
expect(result.start.get("minute")).toBe(10);
|
|
25
|
+
|
|
26
|
+
expect(result.start.isCertain("day")).toBe(false);
|
|
27
|
+
expect(result.start.isCertain("month")).toBe(false);
|
|
28
|
+
expect(result.start.isCertain("year")).toBe(false);
|
|
29
|
+
expect(result.start.isCertain("hour")).toBe(true);
|
|
30
|
+
expect(result.start.isCertain("minute")).toBe(true);
|
|
31
|
+
expect(result.start.isCertain("second")).toBe(false);
|
|
32
|
+
expect(result.start.isCertain("millisecond")).toBe(false);
|
|
33
|
+
|
|
34
|
+
expect(result.start).toBeDate(new Date(2012, 7, 10, 8, 10));
|
|
35
|
+
|
|
36
|
+
expect(result.end).not.toBeNull();
|
|
37
|
+
expect(result.end.get("hour")).toBe(12);
|
|
38
|
+
expect(result.end.get("minute")).toBe(32);
|
|
39
|
+
|
|
40
|
+
expect(result.end.isCertain("day")).toBe(false);
|
|
41
|
+
expect(result.end.isCertain("month")).toBe(false);
|
|
42
|
+
expect(result.end.isCertain("year")).toBe(false);
|
|
43
|
+
expect(result.end.isCertain("hour")).toBe(true);
|
|
44
|
+
expect(result.end.isCertain("minute")).toBe(true);
|
|
45
|
+
expect(result.end.isCertain("second")).toBe(false);
|
|
46
|
+
expect(result.end.isCertain("millisecond")).toBe(false);
|
|
47
|
+
|
|
48
|
+
expect(result.end).toBeDate(new Date(2012, 7, 10, 12, 32));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
testSingleCase(chrono.es, " de 6:30pm a 11:00pm ", new Date(2012, 7, 10), (result) => {
|
|
52
|
+
expect(result.index).toBe(1);
|
|
53
|
+
expect(result.text).toBe("de 6:30pm a 11:00pm");
|
|
54
|
+
|
|
55
|
+
expect(result.start).not.toBeNull();
|
|
56
|
+
expect(result.start.get("hour")).toBe(18);
|
|
57
|
+
expect(result.start.get("minute")).toBe(30);
|
|
58
|
+
expect(result.start.get("meridiem")).toBe(1);
|
|
59
|
+
|
|
60
|
+
expect(result.start).toBeDate(new Date(2012, 7, 10, 18, 30));
|
|
61
|
+
|
|
62
|
+
expect(result.end).not.toBeNull();
|
|
63
|
+
expect(result.end.get("hour")).toBe(23);
|
|
64
|
+
expect(result.end.get("minute")).toBe(0);
|
|
65
|
+
expect(result.end.get("meridiem")).toBe(1);
|
|
66
|
+
|
|
67
|
+
expect(result.end).toBeDate(new Date(2012, 7, 10, 23, 0));
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("Test - Date + Time Expression", function () {
|
|
72
|
+
testSingleCase(chrono.es, "Algo pasó el 10 de Agosto de 2012 10:12:59 pm", new Date(2012, 7, 10), (result) => {
|
|
73
|
+
expect(result.index).toBe(13);
|
|
74
|
+
expect(result.text).toBe("10 de Agosto de 2012 10:12:59 pm");
|
|
75
|
+
|
|
76
|
+
expect(result.start.get("year")).toBe(2012);
|
|
77
|
+
expect(result.start.get("month")).toBe(8);
|
|
78
|
+
expect(result.start.get("day")).toBe(10);
|
|
79
|
+
expect(result.start.get("hour")).toBe(22);
|
|
80
|
+
expect(result.start.get("minute")).toBe(12);
|
|
81
|
+
expect(result.start.get("second")).toBe(59);
|
|
82
|
+
expect(result.start.get("millisecond")).toBe(0);
|
|
83
|
+
expect(result.start.isCertain("millisecond")).toBe(false);
|
|
84
|
+
|
|
85
|
+
expect(result.start).toBeDate(new Date(2012, 8 - 1, 10, 22, 12, 59));
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("Test - Time Expression's Meridiem imply", function () {
|
|
90
|
+
testSingleCase(chrono.es, "de 1pm a 3", new Date(2012, 7, 10), (result) => {
|
|
91
|
+
expect(result.index).toBe(0);
|
|
92
|
+
expect(result.text).toBe("de 1pm a 3");
|
|
93
|
+
|
|
94
|
+
expect(result.start.get("year")).toBe(2012);
|
|
95
|
+
expect(result.start.get("month")).toBe(8);
|
|
96
|
+
expect(result.start.get("day")).toBe(10);
|
|
97
|
+
expect(result.start.get("hour")).toBe(13);
|
|
98
|
+
expect(result.start.get("minute")).toBe(0);
|
|
99
|
+
expect(result.start.get("second")).toBe(0);
|
|
100
|
+
expect(result.start.get("millisecond")).toBe(0);
|
|
101
|
+
expect(result.start.get("meridiem")).toBe(1);
|
|
102
|
+
expect(result.start.isCertain("meridiem")).toBe(true);
|
|
103
|
+
|
|
104
|
+
expect(result.end.get("year")).toBe(2012);
|
|
105
|
+
expect(result.end.get("month")).toBe(8);
|
|
106
|
+
expect(result.end.get("day")).toBe(10);
|
|
107
|
+
expect(result.end.get("hour")).toBe(15);
|
|
108
|
+
expect(result.end.get("minute")).toBe(0);
|
|
109
|
+
expect(result.end.get("second")).toBe(0);
|
|
110
|
+
expect(result.end.get("millisecond")).toBe(0);
|
|
111
|
+
expect(result.end.isCertain("meridiem")).toBe(true);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("Test - Random date + time expression", function () {
|
|
116
|
+
testSingleCase(chrono.es, "lunes 4/29/2013 630-930am", (result, text) => {
|
|
117
|
+
expect(result.text).toBe(text);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
testSingleCase(chrono.es, "martes 5/1/2013 1115am", (result, text) => {
|
|
121
|
+
expect(result.text).toBe(text);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
testSingleCase(chrono.es, "miércoles 5/3/2013 1230pm", (result, text) => {
|
|
125
|
+
expect(result.text).toBe(text);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
testSingleCase(chrono.es, "domingo 5/6/2013 750am-910am", (result, text) => {
|
|
129
|
+
expect(result.text).toBe(text);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
testSingleCase(chrono.es, "lunes 5/13/2013 630-930am", (result, text) => {
|
|
133
|
+
expect(result.text).toBe(text);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
testSingleCase(chrono.es, "miércoles 5/15/2013 1030am", (result, text) => {
|
|
137
|
+
expect(result.text).toBe(text);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
testSingleCase(chrono.es, "jueves 6/21/2013 2:30", (result, text) => {
|
|
141
|
+
expect(result.text).toBe(text);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
testSingleCase(chrono.es, "martes 7/2/2013 1-230 pm", (result, text) => {
|
|
145
|
+
expect(result.text).toBe(text);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
testSingleCase(chrono.es, "Lunes, 6/24/2013, 7:00pm - 8:30pm", (result, text) => {
|
|
149
|
+
expect(result.text).toBe(text);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
testSingleCase(chrono.es, "Miércoles, 3 Julio de 2013 a las 2pm", (result, text) => {
|
|
153
|
+
expect(result.text).toBe(text);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
testSingleCase(chrono.es, "6pm", (result, text) => {
|
|
157
|
+
expect(result.text).toBe(text);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
testSingleCase(chrono.es, "6 pm", (result, text) => {
|
|
161
|
+
expect(result.text).toBe(text);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
testSingleCase(chrono.es, "7-10pm", (result, text) => {
|
|
165
|
+
expect(result.text).toBe(text);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
testSingleCase(chrono.es, "11.1pm", (result, text) => {
|
|
169
|
+
expect(result.text).toBe(text);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
testSingleCase(chrono.es, "las 12", (result, text) => {
|
|
173
|
+
expect(result.text).toBe(text);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -44,6 +44,12 @@ test("Test - Positive time units", () => {
|
|
|
44
44
|
expect(result.start).toBeDate(new Date(2016, 10 - 1, 1, 14));
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
testSingleCase(chrono.ru, "спустя 2 часа", new Date(2016, 10 - 1, 1, 12), (result, text) => {
|
|
48
|
+
expect(result.index).toBe(0);
|
|
49
|
+
expect(result.text).toBe(text);
|
|
50
|
+
expect(result.start).toBeDate(new Date(2016, 10 - 1, 1, 14));
|
|
51
|
+
});
|
|
52
|
+
|
|
47
53
|
testSingleCase(chrono.ru, "через три месяца", new Date(2016, 10 - 1, 1, 12), (result, text) => {
|
|
48
54
|
expect(result.index).toBe(0);
|
|
49
55
|
expect(result.text).toBe(text);
|
|
@@ -67,6 +73,12 @@ test("Test - Positive time units", () => {
|
|
|
67
73
|
expect(result.text).toBe(text);
|
|
68
74
|
expect(result.start).toBeDate(new Date(2021, 11 - 1, 22, 12, 11, 32, 6));
|
|
69
75
|
});
|
|
76
|
+
|
|
77
|
+
testSingleCase(chrono.ru, "спустя год", new Date(2020, 11 - 1, 22, 12, 11, 32, 6), (result, text) => {
|
|
78
|
+
expect(result.index).toBe(0);
|
|
79
|
+
expect(result.text).toBe(text);
|
|
80
|
+
expect(result.start).toBeDate(new Date(2021, 11 - 1, 22, 12, 11, 32, 6));
|
|
81
|
+
});
|
|
70
82
|
});
|
|
71
83
|
|
|
72
84
|
test("Test - Negative time units", () => {
|