@sprucelabs/calendar-utils 31.3.2 → 31.3.3
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.
|
@@ -3,7 +3,7 @@ import { AbstractParser } from '../AbstractParser.js';
|
|
|
3
3
|
export default class TimeParser extends AbstractParser {
|
|
4
4
|
parse(str, date, context) {
|
|
5
5
|
var _a;
|
|
6
|
-
const match = (_a = str.match(/(\d{1,2})(:(\d{2}))? ?(am
|
|
6
|
+
const match = (_a = str.match(/(\d{1,2})(:(\d{2}))? ?(am?|pm?)?/)) === null || _a === void 0 ? void 0 : _a[0];
|
|
7
7
|
if (!match) {
|
|
8
8
|
return str;
|
|
9
9
|
}
|
|
@@ -16,7 +16,7 @@ export default class TimeParser extends AbstractParser {
|
|
|
16
16
|
if (match.includes(':')) {
|
|
17
17
|
date.minute = parseInt(match.split(':')[1], 10);
|
|
18
18
|
}
|
|
19
|
-
if (match.includes('
|
|
19
|
+
if (match.includes('p')) {
|
|
20
20
|
date.hour += 12;
|
|
21
21
|
}
|
|
22
22
|
else if (date.hour === 12 && match.includes('am')) {
|
|
@@ -8,7 +8,7 @@ const AbstractParser_1 = require("../AbstractParser");
|
|
|
8
8
|
class TimeParser extends AbstractParser_1.AbstractParser {
|
|
9
9
|
parse(str, date, context) {
|
|
10
10
|
var _a;
|
|
11
|
-
const match = (_a = str.match(/(\d{1,2})(:(\d{2}))? ?(am
|
|
11
|
+
const match = (_a = str.match(/(\d{1,2})(:(\d{2}))? ?(am?|pm?)?/)) === null || _a === void 0 ? void 0 : _a[0];
|
|
12
12
|
if (!match) {
|
|
13
13
|
return str;
|
|
14
14
|
}
|
|
@@ -21,7 +21,7 @@ class TimeParser extends AbstractParser_1.AbstractParser {
|
|
|
21
21
|
if (match.includes(':')) {
|
|
22
22
|
date.minute = parseInt(match.split(':')[1], 10);
|
|
23
23
|
}
|
|
24
|
-
if (match.includes('
|
|
24
|
+
if (match.includes('p')) {
|
|
25
25
|
date.hour += 12;
|
|
26
26
|
}
|
|
27
27
|
else if (date.hour === 12 && match.includes('am')) {
|