@sprucelabs/calendar-utils 39.0.292 → 40.0.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.
- package/build/.spruce/errors/calendarUtils/invalidTimezoneName.schema.js +3 -3
- package/build/.spruce/errors/errors.types.d.ts +2 -2
- package/build/.spruce/errors/errors.types.js +0 -2
- package/build/.spruce/errors/options.types.d.ts +2 -2
- package/build/.spruce/schemas/calendarUtils/v2021_05_19/calendarEvent.schema.js +121 -59
- package/build/.spruce/schemas/calendarUtils/v2021_05_19/calendarEventLineIcon.schema.js +175 -5
- package/build/.spruce/schemas/calendarUtils/v2021_05_19/calendarEventTarget.schema.js +11 -11
- package/build/.spruce/schemas/calendarUtils/v2021_05_19/eventExclusionDate.schema.js +7 -7
- package/build/.spruce/schemas/calendarUtils/v2021_05_19/eventTimeBlock.schema.js +13 -13
- package/build/.spruce/schemas/fields/fields.types.d.ts +1 -1
- package/build/.spruce/schemas/schemas.types.d.ts +840 -648
- package/build/.spruce/schemas/schemas.types.js +0 -2
- package/build/errors/SpruceError.d.ts +1 -1
- package/build/errors/SpruceError.js +1 -1
- package/build/esm/.spruce/errors/errors.types.d.ts +2 -2
- package/build/esm/.spruce/errors/errors.types.js +0 -2
- package/build/esm/.spruce/errors/options.types.d.ts +2 -2
- package/build/esm/.spruce/schemas/calendarUtils/v2021_05_19/calendarEvent.schema.js +121 -59
- package/build/esm/.spruce/schemas/calendarUtils/v2021_05_19/calendarEventLineIcon.schema.js +175 -5
- package/build/esm/.spruce/schemas/calendarUtils/v2021_05_19/calendarEventTarget.schema.js +11 -11
- package/build/esm/.spruce/schemas/calendarUtils/v2021_05_19/eventExclusionDate.schema.js +7 -7
- package/build/esm/.spruce/schemas/calendarUtils/v2021_05_19/eventTimeBlock.schema.js +13 -13
- package/build/esm/.spruce/schemas/schemas.types.d.ts +840 -648
- package/build/esm/.spruce/schemas/schemas.types.js +0 -2
- package/build/esm/constants.d.ts +2 -2
- package/build/esm/errors/SpruceError.d.ts +1 -1
- package/build/esm/index.d.ts +1 -1
- package/build/esm/locales/Locale.js +1 -1
- package/build/esm/parsing/strategies/DowParser.js +3 -2
- package/build/esm/schemas/v2021_05_19/calendarEvent.builder.d.ts +8 -8
- package/build/esm/types/calendar.types.d.ts +3 -3
- package/build/esm/utilities/PeopleSorter.d.ts +2 -2
- package/build/esm/utilities/PeopleSorter.js +3 -1
- package/build/esm/utilities/calendar.utility.d.ts +3 -3
- package/build/esm/utilities/date.utility.js +1 -1
- package/build/esm/utilities/duration.utility.d.ts +3 -1
- package/build/esm/utilities/duration.utility.js +3 -2
- package/build/index.d.ts +1 -1
- package/build/locales/DateUtilDecorator.js +25 -12
- package/build/locales/Locale.js +7 -5
- package/build/locales/TimezoneChoiceSorter.js +1 -0
- package/build/parsing/AbstractParser.js +2 -0
- package/build/parsing/DateParser.js +8 -2
- package/build/parsing/ParserFactory.js +9 -7
- package/build/parsing/strategies/DowParser.js +4 -4
- package/build/parsing/strategies/TimeParser.js +3 -4
- package/build/parsing/strategies/WeekParser.js +1 -2
- package/build/schemas/v2021_05_19/calendarEvent.builder.js +5 -2
- package/build/types/calendar.types.d.ts +3 -3
- package/build/utilities/PeopleSorter.d.ts +2 -2
- package/build/utilities/PeopleSorter.js +9 -9
- package/build/utilities/RepeatingRuleTextGenerator.js +17 -16
- package/build/utilities/calendar.utility.js +10 -6
- package/build/utilities/date.utility.js +2 -3
- package/build/utilities/duration.utility.d.ts +3 -1
- package/build/utilities/duration.utility.js +4 -3
- package/build/utilities/sortTimezoneChoices.js +5 -3
- package/package.json +21 -22
- package/tsconfig.json +3 -4
package/build/esm/constants.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export declare const repeats: {
|
|
|
14
14
|
};
|
|
15
15
|
export declare const lineIcons: readonly ["sprucebot", "add-circle", "chevron-left", "document-text", "link-angle", "play-circle", "star", "add-square", "chevron-right", "download-cloud", "link-flat", "present", "sun", "add", "chevron-up", "download", "loader", "refresh-circle", "tag", "alarm", "clipboard", "edit-box", "location-pin", "refresh", "time", "arrow-back", "clock", "edit-line", "lock", "repeat", "tool", "arrow-down-circle", "close-circle", "email", "map", "restricted", "trending-down", "arrow-down", "close-square", "emoji-happy", "message-circle", "rotate", "trending-up", "arrow-next", "close", "emoji-sad", "message-square", "search-no", "triangle", "arrow-up-circle", "code", "external-link", "mic-off", "search", "unlock", "arrow-up", "coffee", "fav-heart", "mic-on", "selector-checked", "upload-cloud", "attachment", "command", "flag", "minus-circle", "selector-circle-filled", "upload", "award-badge", "corner-down-left", "flip-01", "minus-square", "selector-circle", "user-add", "binoculars", "corner-down-right", "flip-02", "money-sign", "send", "user-delete", "bolt", "corner-left-down", "folder", "more-horizontal", "settings-filled", "user", "book-open", "corner-left-up", "globe", "more-vertical", "settings", "users", "book", "corner-right-down", "hash-tag", "notification-off", "share", "video-off", "bookmark", "corner-right-up", "headphones", "notification-on", "shopping-bag", "video", "calendar-add", "corner-up-left", "help-buoy", "object", "shopping-cart", "warning", "calendar", "corner-up-right", "help-circle", "pause-circle", "sort-filter-down", "wifi", "camera", "crop", "home", "phone-unavailable", "sort-filter-up", "zoom-in", "cellphone", "delete", "info", "phone", "sound-off", "zoom-out", "checkmark", "document-blank", "jump", "photo", "sound-on", "chevron-down", "document-new", "layers", "picked", "star-filled"];
|
|
16
16
|
export declare const lineIconChoices: {
|
|
17
|
-
value: "object" | "
|
|
18
|
-
label: "object" | "
|
|
17
|
+
value: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
18
|
+
label: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
19
19
|
}[];
|
|
20
20
|
export declare const eventStyles: string[];
|
|
21
21
|
export declare const eventStyleChoices: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseSpruceError from '@sprucelabs/error';
|
|
2
|
-
import ErrorOptions from
|
|
2
|
+
import ErrorOptions from './../.spruce/errors/options.types';
|
|
3
3
|
export default class SpruceError extends BaseSpruceError<ErrorOptions> {
|
|
4
4
|
/** An easy to understand version of the errors */
|
|
5
5
|
friendlyMessage(): string;
|
package/build/esm/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export { default as DateParser } from './parsing/DateParser';
|
|
|
19
19
|
export { default as sortTimezoneChoices } from './utilities/sortTimezoneChoices';
|
|
20
20
|
export { default as RepeatingRuleTextGenerator } from './utilities/RepeatingRuleTextGenerator';
|
|
21
21
|
export * from './dates';
|
|
22
|
-
export { SpruceSchemas } from
|
|
22
|
+
export { SpruceSchemas } from './.spruce/schemas/schemas.types';
|
|
23
23
|
export * from './constants';
|
|
@@ -73,7 +73,7 @@ export default class LocaleImpl extends AbstractEventEmitter {
|
|
|
73
73
|
return this.zoneNameByOffset[offset];
|
|
74
74
|
}
|
|
75
75
|
zoneNameToOffsetMinutes(name, onDate) {
|
|
76
|
-
const results = getTimezoneOffset(name, onDate);
|
|
76
|
+
const results = getTimezoneOffset(name, onDate || Date.now());
|
|
77
77
|
if (isNaN(results)) {
|
|
78
78
|
throw new SpruceError({
|
|
79
79
|
code: 'INVALID_TIMEZONE_NAME',
|
|
@@ -43,8 +43,9 @@ export default class DowParser extends AbstractParser {
|
|
|
43
43
|
}
|
|
44
44
|
const match = (_a = str.match(/(monday|tuesday|wednesday|thursday|friday|saturday|sunday)/)) === null || _a === void 0 ? void 0 : _a[0];
|
|
45
45
|
if (match) {
|
|
46
|
-
while (dateUtil
|
|
47
|
-
|
|
46
|
+
while (dateUtil
|
|
47
|
+
.format(dateUtil.date(date), 'EEEE')
|
|
48
|
+
.toLocaleLowerCase() !== match) {
|
|
48
49
|
date.day += 1;
|
|
49
50
|
}
|
|
50
51
|
str = str.replace(match, '');
|
|
@@ -44,8 +44,8 @@ export declare const eventTimeBlocksSchema: {
|
|
|
44
44
|
isRequired: true;
|
|
45
45
|
options: {
|
|
46
46
|
choices: {
|
|
47
|
-
value: "object" | "
|
|
48
|
-
label: "object" | "
|
|
47
|
+
value: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
48
|
+
label: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
49
49
|
}[];
|
|
50
50
|
};
|
|
51
51
|
};
|
|
@@ -68,8 +68,8 @@ export declare const eventTimeBlocksSchema: {
|
|
|
68
68
|
isRequired: true;
|
|
69
69
|
options: {
|
|
70
70
|
choices: {
|
|
71
|
-
value: "object" | "
|
|
72
|
-
label: "object" | "
|
|
71
|
+
value: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
72
|
+
label: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
73
73
|
}[];
|
|
74
74
|
};
|
|
75
75
|
};
|
|
@@ -191,8 +191,8 @@ declare const _default: {
|
|
|
191
191
|
isRequired: true;
|
|
192
192
|
options: {
|
|
193
193
|
choices: {
|
|
194
|
-
value: "object" | "
|
|
195
|
-
label: "object" | "
|
|
194
|
+
value: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
195
|
+
label: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
196
196
|
}[];
|
|
197
197
|
};
|
|
198
198
|
};
|
|
@@ -215,8 +215,8 @@ declare const _default: {
|
|
|
215
215
|
isRequired: true;
|
|
216
216
|
options: {
|
|
217
217
|
choices: {
|
|
218
|
-
value: "object" | "
|
|
219
|
-
label: "object" | "
|
|
218
|
+
value: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
219
|
+
label: "object" | "sprucebot" | "add-circle" | "chevron-left" | "document-text" | "link-angle" | "play-circle" | "star" | "add-square" | "chevron-right" | "download-cloud" | "link-flat" | "present" | "sun" | "add" | "chevron-up" | "download" | "loader" | "refresh-circle" | "tag" | "alarm" | "clipboard" | "edit-box" | "location-pin" | "refresh" | "time" | "arrow-back" | "clock" | "edit-line" | "lock" | "repeat" | "tool" | "arrow-down-circle" | "close-circle" | "email" | "map" | "restricted" | "trending-down" | "arrow-down" | "close-square" | "emoji-happy" | "message-circle" | "rotate" | "trending-up" | "arrow-next" | "close" | "emoji-sad" | "message-square" | "search-no" | "triangle" | "arrow-up-circle" | "code" | "external-link" | "mic-off" | "search" | "unlock" | "arrow-up" | "coffee" | "fav-heart" | "mic-on" | "selector-checked" | "upload-cloud" | "attachment" | "command" | "flag" | "minus-circle" | "selector-circle-filled" | "upload" | "award-badge" | "corner-down-left" | "flip-01" | "minus-square" | "selector-circle" | "user-add" | "binoculars" | "corner-down-right" | "flip-02" | "money-sign" | "send" | "user-delete" | "bolt" | "corner-left-down" | "folder" | "more-horizontal" | "settings-filled" | "user" | "book-open" | "corner-left-up" | "globe" | "more-vertical" | "settings" | "users" | "book" | "corner-right-down" | "hash-tag" | "notification-off" | "share" | "video-off" | "bookmark" | "corner-right-up" | "headphones" | "notification-on" | "shopping-bag" | "video" | "calendar-add" | "corner-up-left" | "help-buoy" | "shopping-cart" | "warning" | "calendar" | "corner-up-right" | "help-circle" | "pause-circle" | "sort-filter-down" | "wifi" | "camera" | "crop" | "home" | "phone-unavailable" | "sort-filter-up" | "zoom-in" | "cellphone" | "delete" | "info" | "phone" | "sound-off" | "zoom-out" | "checkmark" | "document-blank" | "jump" | "photo" | "sound-on" | "chevron-down" | "document-new" | "layers" | "picked" | "star-filled";
|
|
220
220
|
}[];
|
|
221
221
|
};
|
|
222
222
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { timezoneChoices } from '@sprucelabs/spruce-core-schemas';
|
|
2
|
-
import { SpruceSchemas } from
|
|
2
|
+
import { SpruceSchemas } from './../.spruce/schemas/schemas.types';
|
|
3
3
|
import LocaleImpl from '../locales/Locale';
|
|
4
4
|
import dateUtil from '../utilities/date.utility';
|
|
5
5
|
type D = typeof dateUtil;
|
|
@@ -16,11 +16,11 @@ export type TimezoneChoices = typeof timezoneChoices;
|
|
|
16
16
|
export type TimezoneName = TimezoneChoices[number]['value'];
|
|
17
17
|
export type Repeats = NonNullable<CalendarEvent['repeats']>;
|
|
18
18
|
export type Locale = Pick<LocaleImpl, 'on' | 'getZoneName' | 'offsetMinutesToZoneName' | 'getTimezoneOffsetMinutes' | 'setTimezoneOffsetMinutes' | 'setZoneName' | 'zoneNameToOffsetMinutes'>;
|
|
19
|
-
export
|
|
19
|
+
export interface SorterCalendarEvent {
|
|
20
20
|
id: string;
|
|
21
21
|
groupId?: string;
|
|
22
22
|
startDateTimeMs: number;
|
|
23
23
|
personId: string;
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
export type RepeatingCalendarEvent = Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>;
|
|
26
26
|
export {};
|
|
@@ -48,7 +48,9 @@ export default class PeopleSorter {
|
|
|
48
48
|
}
|
|
49
49
|
return false;
|
|
50
50
|
});
|
|
51
|
-
const groupsIds = selectedEvents
|
|
51
|
+
const groupsIds = selectedEvents
|
|
52
|
+
.map((e) => e.groupId)
|
|
53
|
+
.filter((g) => !!g);
|
|
52
54
|
const matchOnGroup = groupsIds.length > 0
|
|
53
55
|
? this.events.filter((e) => !selectedEvents.find((se) => se.id === e.id) &&
|
|
54
56
|
groupsIds.indexOf(e.groupId) > -1)
|
|
@@ -17,10 +17,10 @@ declare const calendarUtil: {
|
|
|
17
17
|
sat: import("rrule").Weekday;
|
|
18
18
|
sun: import("rrule").Weekday;
|
|
19
19
|
};
|
|
20
|
-
applyRuleAndGetEvents(e: RepeatingCalendarEvent, dateUntil: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "
|
|
21
|
-
applyRuleAndGetEventsWithoutExclusion(e: Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>, dateUntil: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "
|
|
20
|
+
applyRuleAndGetEvents(e: RepeatingCalendarEvent, dateUntil: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "startDateTimeMs" | "timeBlocks" | "repeats" | "daysOfWeek" | "daysOfMonth" | "repeatsUntil" | "occurrences" | "interval" | "nthOccurrences" | "nthInRepeating" | "totalInRepeating">[];
|
|
21
|
+
applyRuleAndGetEventsWithoutExclusion(e: Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>, dateUntil: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "startDateTimeMs" | "timeBlocks" | "repeats" | "daysOfWeek" | "daysOfMonth" | "repeatsUntil" | "occurrences" | "interval" | "nthOccurrences" | "nthInRepeating" | "totalInRepeating">[];
|
|
22
22
|
mapRulesToEvents(rule: RRule, e: Pick<CalendarEvent, 'startDateTimeMs'>, timezone: TimezoneName): import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent[];
|
|
23
23
|
isExcluded(e: Pick<CalendarEvent, 'exclusionDates' | 'startDateTimeMs'>): boolean;
|
|
24
|
-
getEventFromRangeByDate(values: RepeatingCalendarEvent, date: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "
|
|
24
|
+
getEventFromRangeByDate(values: RepeatingCalendarEvent, date: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "startDateTimeMs" | "timeBlocks" | "repeats" | "daysOfWeek" | "daysOfMonth" | "repeatsUntil" | "occurrences" | "interval" | "nthOccurrences" | "nthInRepeating" | "totalInRepeating"> | undefined;
|
|
25
25
|
};
|
|
26
26
|
export default calendarUtil;
|
|
@@ -544,7 +544,7 @@ const dateUtil = {
|
|
|
544
544
|
},
|
|
545
545
|
isSameDay(timestamp1, timestamp2) {
|
|
546
546
|
const { day, year, month } = this.splitDate(timestamp1);
|
|
547
|
-
const { day: day2, year: year2, month: month2 } = this.splitDate(timestamp2);
|
|
547
|
+
const { day: day2, year: year2, month: month2, } = this.splitDate(timestamp2);
|
|
548
548
|
return day === day2 && year === year2 && month === month2;
|
|
549
549
|
},
|
|
550
550
|
getTotalDaysInMonth(year, month) {
|
|
@@ -59,13 +59,14 @@ const durationUtil = {
|
|
|
59
59
|
else if (daysFromNow < -1) {
|
|
60
60
|
prefix = past;
|
|
61
61
|
startDateAndTime =
|
|
62
|
-
this.dates.format(start, 'MMM do') +
|
|
62
|
+
this.dates.format(start, 'MMM do') +
|
|
63
|
+
` (${daysFromNow * -1} days ago)`;
|
|
63
64
|
}
|
|
64
65
|
startDateAndTime += ` @ ${this.dates.format(start, 'h:mmaaa')}`.replace(':00', '');
|
|
65
66
|
return optionallUcFirst(`${prefix ? `${prefix} ` : ''}${startDateAndTime}`, shouldCapitalize);
|
|
66
67
|
},
|
|
67
68
|
renderTimeRange(date1, date2) {
|
|
68
|
-
return this.dates.formatTime(date1) + ' to ' + this.dates.formatTime(date2);
|
|
69
|
+
return (this.dates.formatTime(date1) + ' to ' + this.dates.formatTime(date2));
|
|
69
70
|
},
|
|
70
71
|
};
|
|
71
72
|
export default durationUtil;
|
package/build/index.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export { default as DateParser } from './parsing/DateParser';
|
|
|
19
19
|
export { default as sortTimezoneChoices } from './utilities/sortTimezoneChoices';
|
|
20
20
|
export { default as RepeatingRuleTextGenerator } from './utilities/RepeatingRuleTextGenerator';
|
|
21
21
|
export * from './dates';
|
|
22
|
-
export { SpruceSchemas } from
|
|
22
|
+
export { SpruceSchemas } from './.spruce/schemas/schemas.types';
|
|
23
23
|
export * from './constants';
|
|
@@ -4,15 +4,19 @@ exports.calculateOffsetAtDate = void 0;
|
|
|
4
4
|
const schema_1 = require("@sprucelabs/schema");
|
|
5
5
|
const date_fns_tz_1 = require("date-fns-tz");
|
|
6
6
|
class DateUtilDecorator {
|
|
7
|
+
locale;
|
|
7
8
|
constructor(locale) {
|
|
8
9
|
(0, schema_1.assertOptions)({ locale }, ['locale']);
|
|
9
10
|
this.locale = locale;
|
|
10
11
|
}
|
|
11
12
|
makeLocaleAware(dateUtil) {
|
|
12
13
|
(0, schema_1.assertOptions)({ dateUtil }, ['dateUtil']);
|
|
13
|
-
return
|
|
14
|
+
return {
|
|
15
|
+
...dateUtil,
|
|
14
16
|
//@ts-ignore
|
|
15
|
-
__beenDecorated: true,
|
|
17
|
+
__beenDecorated: true,
|
|
18
|
+
__locale: this.locale,
|
|
19
|
+
date: (date) => {
|
|
16
20
|
let value;
|
|
17
21
|
if (!date) {
|
|
18
22
|
const d = new Date();
|
|
@@ -25,26 +29,35 @@ class DateUtilDecorator {
|
|
|
25
29
|
return value - offset;
|
|
26
30
|
}
|
|
27
31
|
return this.addOffset(value);
|
|
28
|
-
},
|
|
32
|
+
},
|
|
33
|
+
setTimeOfDay: (...args) => {
|
|
29
34
|
return this.addOffset(dateUtil.setTimeOfDay(...args));
|
|
30
|
-
},
|
|
35
|
+
},
|
|
36
|
+
format: (date, format) => {
|
|
31
37
|
return dateUtil.format(this.addOffset(date, false), format);
|
|
32
|
-
},
|
|
38
|
+
},
|
|
39
|
+
getStartOfDay: (date) => {
|
|
33
40
|
return this.addOffset(dateUtil.getStartOfDay(this.offsetDate(date)));
|
|
34
|
-
},
|
|
41
|
+
},
|
|
42
|
+
getEndOfDay: (date) => {
|
|
35
43
|
return this.addOffset(dateUtil.getEndOfDay(this.offsetDate(date)));
|
|
36
|
-
},
|
|
44
|
+
},
|
|
45
|
+
getStartOfMonth: (date) => {
|
|
37
46
|
return this.addOffset(dateUtil.getStartOfMonth(this.offsetDate(date)));
|
|
38
|
-
},
|
|
47
|
+
},
|
|
48
|
+
getEndOfMonth: (date) => {
|
|
39
49
|
return this.addOffset(dateUtil.getEndOfMonth(this.offsetDate(date)));
|
|
40
|
-
},
|
|
50
|
+
},
|
|
51
|
+
splitDate: (timestamp) => {
|
|
41
52
|
return dateUtil.splitDate(this.addOffset(timestamp, false));
|
|
42
|
-
},
|
|
53
|
+
},
|
|
54
|
+
addMonths: (date, months) => {
|
|
43
55
|
return this.addOffset(dateUtil.addMonths(this.addOffset(date, false), months));
|
|
44
|
-
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
45
58
|
}
|
|
46
59
|
offsetDate(date) {
|
|
47
|
-
return this.addOffset(date
|
|
60
|
+
return this.addOffset(date ?? new Date().getTime(), false);
|
|
48
61
|
}
|
|
49
62
|
addOffset(value, shouldInverse = true) {
|
|
50
63
|
let offset = this.calculateOffset(value);
|
package/build/locales/Locale.js
CHANGED
|
@@ -11,11 +11,13 @@ const date_fns_tz_1 = require("date-fns-tz");
|
|
|
11
11
|
const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
|
|
12
12
|
const TimezoneChoiceSorter_1 = __importDefault(require("./TimezoneChoiceSorter"));
|
|
13
13
|
class LocaleImpl extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
14
|
+
zoneNameByOffset = {};
|
|
15
|
+
offsetsForDate = {};
|
|
16
|
+
offset = new Date().getTimezoneOffset() * -1;
|
|
17
|
+
currentZone;
|
|
18
|
+
_timezoneChoices;
|
|
14
19
|
constructor() {
|
|
15
20
|
super(localeContract);
|
|
16
|
-
this.zoneNameByOffset = {};
|
|
17
|
-
this.offsetsForDate = {};
|
|
18
|
-
this.offset = new Date().getTimezoneOffset() * -1;
|
|
19
21
|
}
|
|
20
22
|
setTimezoneOffsetMinutes(offset) {
|
|
21
23
|
(0, schema_1.assertOptions)({ offset }, ['offset']);
|
|
@@ -26,7 +28,7 @@ class LocaleImpl extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
26
28
|
if (onDate || timezone) {
|
|
27
29
|
const date = onDate ? onDate : Date.now();
|
|
28
30
|
const dateRoundedToNearestHour = date - (date % 3600000);
|
|
29
|
-
const zone = timezone
|
|
31
|
+
const zone = timezone ?? this.getZoneName();
|
|
30
32
|
const key = `${zone}-${dateRoundedToNearestHour}`;
|
|
31
33
|
if (!(key in this.offsetsForDate)) {
|
|
32
34
|
this.offsetsForDate[key] = this.zoneNameToOffsetMinutes(zone, onDate);
|
|
@@ -67,7 +69,7 @@ class LocaleImpl extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
67
69
|
return this.zoneNameByOffset[offset];
|
|
68
70
|
}
|
|
69
71
|
zoneNameToOffsetMinutes(name, onDate) {
|
|
70
|
-
const results = (0, date_fns_tz_1.getTimezoneOffset)(name, onDate);
|
|
72
|
+
const results = (0, date_fns_tz_1.getTimezoneOffset)(name, onDate || Date.now());
|
|
71
73
|
if (isNaN(results)) {
|
|
72
74
|
throw new SpruceError_1.default({
|
|
73
75
|
code: 'INVALID_TIMEZONE_NAME',
|
|
@@ -7,8 +7,10 @@ const schema_1 = require("@sprucelabs/schema");
|
|
|
7
7
|
const date_utility_1 = __importDefault(require("../utilities/date.utility"));
|
|
8
8
|
const ParserFactory_1 = __importDefault(require("./ParserFactory"));
|
|
9
9
|
class DateParser {
|
|
10
|
+
now;
|
|
11
|
+
parsers = [];
|
|
12
|
+
locale;
|
|
10
13
|
constructor(now, locale) {
|
|
11
|
-
this.parsers = [];
|
|
12
14
|
this.now = now;
|
|
13
15
|
this.locale = locale;
|
|
14
16
|
const parsers = ParserFactory_1.default.Factory(now, locale);
|
|
@@ -37,7 +39,11 @@ class DateParser {
|
|
|
37
39
|
if (parsed === original) {
|
|
38
40
|
return null;
|
|
39
41
|
}
|
|
40
|
-
let normalized = date_utility_1.default.date(
|
|
42
|
+
let normalized = date_utility_1.default.date({
|
|
43
|
+
...date,
|
|
44
|
+
milliseconds: 0,
|
|
45
|
+
second: 0,
|
|
46
|
+
});
|
|
41
47
|
return normalized;
|
|
42
48
|
}
|
|
43
49
|
}
|
|
@@ -9,6 +9,7 @@ const TimeParser_1 = __importDefault(require("./strategies/TimeParser"));
|
|
|
9
9
|
const WeekParser_1 = __importDefault(require("./strategies/WeekParser"));
|
|
10
10
|
const YearParser_1 = __importDefault(require("./strategies/YearParser"));
|
|
11
11
|
class ParserFactory {
|
|
12
|
+
locale;
|
|
12
13
|
all() {
|
|
13
14
|
return [
|
|
14
15
|
this.Parser('Year'),
|
|
@@ -18,14 +19,15 @@ class ParserFactory {
|
|
|
18
19
|
this.Parser('Time'),
|
|
19
20
|
];
|
|
20
21
|
}
|
|
22
|
+
now;
|
|
23
|
+
strategies = {
|
|
24
|
+
Year: () => new YearParser_1.default(this.now, this.locale),
|
|
25
|
+
Month: () => new MonthParser_1.default(this.now, this.locale),
|
|
26
|
+
Dow: () => new DowParser_1.default(this.now, this.locale),
|
|
27
|
+
Time: () => new TimeParser_1.default(this.now, this.locale),
|
|
28
|
+
Week: () => new WeekParser_1.default(this.now, this.locale),
|
|
29
|
+
};
|
|
21
30
|
constructor(now, locale) {
|
|
22
|
-
this.strategies = {
|
|
23
|
-
Year: () => new YearParser_1.default(this.now, this.locale),
|
|
24
|
-
Month: () => new MonthParser_1.default(this.now, this.locale),
|
|
25
|
-
Dow: () => new DowParser_1.default(this.now, this.locale),
|
|
26
|
-
Time: () => new TimeParser_1.default(this.now, this.locale),
|
|
27
|
-
Week: () => new WeekParser_1.default(this.now, this.locale),
|
|
28
|
-
};
|
|
29
31
|
this.now = now;
|
|
30
32
|
this.locale = locale;
|
|
31
33
|
}
|
|
@@ -7,7 +7,6 @@ const date_utility_1 = __importDefault(require("../../utilities/date.utility"));
|
|
|
7
7
|
const AbstractParser_1 = require("../AbstractParser");
|
|
8
8
|
class DowParser extends AbstractParser_1.AbstractParser {
|
|
9
9
|
parse(str, date) {
|
|
10
|
-
var _a;
|
|
11
10
|
if (str.includes('tomorrow')) {
|
|
12
11
|
date.day += 1;
|
|
13
12
|
str = str.replace('tomorrow', '');
|
|
@@ -46,10 +45,11 @@ class DowParser extends AbstractParser_1.AbstractParser {
|
|
|
46
45
|
const re = new RegExp(`(^|\\W)${dow.abbr}(\\W|$)`, 'gi');
|
|
47
46
|
str = str.replace(re, `$1${dow.full}$2`);
|
|
48
47
|
}
|
|
49
|
-
const match =
|
|
48
|
+
const match = str.match(/(monday|tuesday|wednesday|thursday|friday|saturday|sunday)/)?.[0];
|
|
50
49
|
if (match) {
|
|
51
|
-
while (date_utility_1.default
|
|
52
|
-
|
|
50
|
+
while (date_utility_1.default
|
|
51
|
+
.format(date_utility_1.default.date(date), 'EEEE')
|
|
52
|
+
.toLocaleLowerCase() !== match) {
|
|
53
53
|
date.day += 1;
|
|
54
54
|
}
|
|
55
55
|
str = str.replace(match, '');
|
|
@@ -7,8 +7,7 @@ const date_utility_1 = __importDefault(require("../../utilities/date.utility"));
|
|
|
7
7
|
const AbstractParser_1 = require("../AbstractParser");
|
|
8
8
|
class TimeParser extends AbstractParser_1.AbstractParser {
|
|
9
9
|
parse(str, date, context) {
|
|
10
|
-
|
|
11
|
-
const matches = (_a = str.match(/(\d{1,2})(:?(\d{1,2}))?\s*([ap]m?)?/)) !== null && _a !== void 0 ? _a : [];
|
|
10
|
+
const matches = str.match(/(\d{1,2})(:?(\d{1,2}))?\s*([ap]m?)?/) ?? [];
|
|
12
11
|
let [match, hour, , minutes, ampm] = matches;
|
|
13
12
|
if (!match) {
|
|
14
13
|
return str;
|
|
@@ -16,7 +15,7 @@ class TimeParser extends AbstractParser_1.AbstractParser {
|
|
|
16
15
|
if (hour) {
|
|
17
16
|
let parsedHour = parseInt(hour, 10);
|
|
18
17
|
if (parsedHour > 12) {
|
|
19
|
-
minutes = hour[1] + (minutes
|
|
18
|
+
minutes = hour[1] + (minutes ?? '');
|
|
20
19
|
hour = hour[0];
|
|
21
20
|
parsedHour = parseInt(hour, 10);
|
|
22
21
|
}
|
|
@@ -29,7 +28,7 @@ class TimeParser extends AbstractParser_1.AbstractParser {
|
|
|
29
28
|
}
|
|
30
29
|
date.minute = parseInt(minutes, 10);
|
|
31
30
|
}
|
|
32
|
-
if (ampm
|
|
31
|
+
if (ampm?.includes('p')) {
|
|
33
32
|
date.hour += 12;
|
|
34
33
|
}
|
|
35
34
|
else if (date.hour === 12 && match.includes('am')) {
|
|
@@ -3,12 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const AbstractParser_1 = require("../AbstractParser");
|
|
4
4
|
class WeekParser extends AbstractParser_1.AbstractParser {
|
|
5
5
|
parse(str, date) {
|
|
6
|
-
var _a;
|
|
7
6
|
if (str.includes('next week')) {
|
|
8
7
|
date.day += 7;
|
|
9
8
|
str = str.replace('next week', '');
|
|
10
9
|
}
|
|
11
|
-
const match =
|
|
10
|
+
const match = str.match(/(\d{1,2}) ?(weeks?)/)?.[0];
|
|
12
11
|
if (match) {
|
|
13
12
|
date.day += parseInt(match, 10) * 7;
|
|
14
13
|
str = str.replace(match, '');
|