@sprucelabs/spruce-calendar-components 22.12.0 → 22.12.1

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.
@@ -5,12 +5,7 @@ export default class DateParser {
5
5
  this.parsers = [];
6
6
  this.now = now;
7
7
  const parsers = ParserFactory.Factory(now);
8
- this.parsers = [
9
- parsers.Parser('Year'),
10
- parsers.Parser('Month'),
11
- parsers.Parser('Dow'),
12
- parsers.Parser('Time'),
13
- ];
8
+ this.parsers = [...parsers.all()];
14
9
  }
15
10
  static Parser(now) {
16
11
  assertOptions({ now }, ['now']);
@@ -33,12 +28,22 @@ export default class DateParser {
33
28
  }
34
29
  }
35
30
  class ParserFactory {
31
+ all() {
32
+ return [
33
+ this.Parser('Year'),
34
+ this.Parser('Month'),
35
+ this.Parser('Dow'),
36
+ this.Parser('Week'),
37
+ this.Parser('Time'),
38
+ ];
39
+ }
36
40
  constructor(now) {
37
41
  this.strategies = {
38
42
  Year: () => new YearParser(this.now),
39
43
  Month: () => new MonthParser(this.now),
40
44
  Dow: () => new DowParser(this.now),
41
45
  Time: () => new TimeParser(this.now),
46
+ Week: () => new WeekParser(this.now),
42
47
  };
43
48
  this.now = now;
44
49
  }
@@ -54,6 +59,21 @@ class AbstractParser {
54
59
  this.now = now;
55
60
  }
56
61
  }
62
+ class WeekParser extends AbstractParser {
63
+ parse(str, date) {
64
+ var _a;
65
+ if (str.includes('next week')) {
66
+ date.day += 7;
67
+ str = str.replace('next week', '');
68
+ }
69
+ const match = (_a = str.match(/(\d{1,2}) ?(weeks?)/)) === null || _a === void 0 ? void 0 : _a[0];
70
+ if (match) {
71
+ date.day += parseInt(match, 10) * 7;
72
+ str = str.replace(match, '');
73
+ }
74
+ return str;
75
+ }
76
+ }
57
77
  class TimeParser extends AbstractParser {
58
78
  parse(str, date, context) {
59
79
  var _a;
@@ -7,12 +7,7 @@ class DateParser {
7
7
  this.parsers = [];
8
8
  this.now = now;
9
9
  const parsers = ParserFactory.Factory(now);
10
- this.parsers = [
11
- parsers.Parser('Year'),
12
- parsers.Parser('Month'),
13
- parsers.Parser('Dow'),
14
- parsers.Parser('Time'),
15
- ];
10
+ this.parsers = [...parsers.all()];
16
11
  }
17
12
  static Parser(now) {
18
13
  (0, schema_1.assertOptions)({ now }, ['now']);
@@ -36,12 +31,22 @@ class DateParser {
36
31
  }
37
32
  exports.default = DateParser;
38
33
  class ParserFactory {
34
+ all() {
35
+ return [
36
+ this.Parser('Year'),
37
+ this.Parser('Month'),
38
+ this.Parser('Dow'),
39
+ this.Parser('Week'),
40
+ this.Parser('Time'),
41
+ ];
42
+ }
39
43
  constructor(now) {
40
44
  this.strategies = {
41
45
  Year: () => new YearParser(this.now),
42
46
  Month: () => new MonthParser(this.now),
43
47
  Dow: () => new DowParser(this.now),
44
48
  Time: () => new TimeParser(this.now),
49
+ Week: () => new WeekParser(this.now),
45
50
  };
46
51
  this.now = now;
47
52
  }
@@ -57,6 +62,21 @@ class AbstractParser {
57
62
  this.now = now;
58
63
  }
59
64
  }
65
+ class WeekParser extends AbstractParser {
66
+ parse(str, date) {
67
+ var _a;
68
+ if (str.includes('next week')) {
69
+ date.day += 7;
70
+ str = str.replace('next week', '');
71
+ }
72
+ const match = (_a = str.match(/(\d{1,2}) ?(weeks?)/)) === null || _a === void 0 ? void 0 : _a[0];
73
+ if (match) {
74
+ date.day += parseInt(match, 10) * 7;
75
+ str = str.replace(match, '');
76
+ }
77
+ return str;
78
+ }
79
+ }
60
80
  class TimeParser extends AbstractParser {
61
81
  parse(str, date, context) {
62
82
  var _a;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-calendar-components",
3
3
  "description": "Calendar components for working with calendars and Sprucebot.",
4
- "version": "22.12.0",
4
+ "version": "22.12.1",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },