@sprucelabs/calendar-utils 31.1.1 → 31.2.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/build/esm/parsing/DateParser.d.ts +1 -1
- package/build/esm/parsing/DateParser.js +4 -0
- package/build/esm/parsing/strategies/DowParser.js +1 -1
- package/build/parsing/DateParser.d.ts +1 -1
- package/build/parsing/DateParser.js +4 -0
- package/build/parsing/strategies/DowParser.js +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@ export default class DateParser {
|
|
|
14
14
|
}
|
|
15
15
|
parse(str) {
|
|
16
16
|
const now = this.now();
|
|
17
|
+
const original = str;
|
|
17
18
|
const date = dateUtil.splitDate(now);
|
|
18
19
|
let parsed = str.toLocaleLowerCase().replace(/[^a-z0-9: ]/g, '');
|
|
19
20
|
const context = {
|
|
@@ -24,6 +25,9 @@ export default class DateParser {
|
|
|
24
25
|
parsed = parser.parse(parsed, date, context);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
28
|
+
if (parsed === original) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
27
31
|
let normalized = dateUtil.date(Object.assign(Object.assign({}, date), { milliseconds: 0, second: 0 }));
|
|
28
32
|
return normalized;
|
|
29
33
|
}
|
|
@@ -46,8 +46,8 @@ export default class DowParser extends AbstractParser {
|
|
|
46
46
|
while (dateUtil.format(dateUtil.date(date), 'EEEE').toLocaleLowerCase() !==
|
|
47
47
|
match) {
|
|
48
48
|
date.day += 1;
|
|
49
|
-
str = str.replace(match, '');
|
|
50
49
|
}
|
|
50
|
+
str = str.replace(match, '');
|
|
51
51
|
}
|
|
52
52
|
return str;
|
|
53
53
|
}
|
|
@@ -19,6 +19,7 @@ class DateParser {
|
|
|
19
19
|
}
|
|
20
20
|
parse(str) {
|
|
21
21
|
const now = this.now();
|
|
22
|
+
const original = str;
|
|
22
23
|
const date = date_utility_1.default.splitDate(now);
|
|
23
24
|
let parsed = str.toLocaleLowerCase().replace(/[^a-z0-9: ]/g, '');
|
|
24
25
|
const context = {
|
|
@@ -29,6 +30,9 @@ class DateParser {
|
|
|
29
30
|
parsed = parser.parse(parsed, date, context);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
33
|
+
if (parsed === original) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
32
36
|
let normalized = date_utility_1.default.date(Object.assign(Object.assign({}, date), { milliseconds: 0, second: 0 }));
|
|
33
37
|
return normalized;
|
|
34
38
|
}
|
|
@@ -51,8 +51,8 @@ class DowParser extends AbstractParser_1.AbstractParser {
|
|
|
51
51
|
while (date_utility_1.default.format(date_utility_1.default.date(date), 'EEEE').toLocaleLowerCase() !==
|
|
52
52
|
match) {
|
|
53
53
|
date.day += 1;
|
|
54
|
-
str = str.replace(match, '');
|
|
55
54
|
}
|
|
55
|
+
str = str.replace(match, '');
|
|
56
56
|
}
|
|
57
57
|
return str;
|
|
58
58
|
}
|