@sprucelabs/calendar-utils 39.0.0 → 39.0.2
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/locales/Locale.js +6 -4
- package/build/esm/types/calendar.types.d.ts +1 -0
- package/build/esm/utilities/calendar.utility.d.ts +1 -2
- package/build/locales/Locale.js +6 -4
- package/build/types/calendar.types.d.ts +1 -0
- package/build/utilities/calendar.utility.d.ts +1 -2
- package/package.json +1 -1
|
@@ -27,11 +27,13 @@ export default class LocaleImpl extends AbstractEventEmitter {
|
|
|
27
27
|
this.currentZone = undefined;
|
|
28
28
|
}
|
|
29
29
|
getTimezoneOffsetMinutes(onDate, timezone) {
|
|
30
|
-
if (onDate) {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
30
|
+
if (onDate || timezone) {
|
|
31
|
+
const date = onDate ? onDate : Date.now();
|
|
32
|
+
const dateRoundedToNearestHour = date - (date % 3600000);
|
|
33
|
+
const zone = timezone !== null && timezone !== void 0 ? timezone : this.getZoneName();
|
|
34
|
+
const key = `${zone}-${dateRoundedToNearestHour}`;
|
|
33
35
|
if (!(key in this.offsetsForDate)) {
|
|
34
|
-
this.offsetsForDate[key] = this.zoneNameToOffsetMinutes(
|
|
36
|
+
this.offsetsForDate[key] = this.zoneNameToOffsetMinutes(zone, onDate);
|
|
35
37
|
}
|
|
36
38
|
return this.offsetsForDate[key];
|
|
37
39
|
}
|
|
@@ -22,4 +22,5 @@ export type SorterCalendarEvent = {
|
|
|
22
22
|
startDateTimeMs: number;
|
|
23
23
|
personId: string;
|
|
24
24
|
};
|
|
25
|
+
export type RepeatingCalendarEvent = Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>;
|
|
25
26
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RRule } from 'rrule';
|
|
2
2
|
import LocaleImpl from '../locales/Locale';
|
|
3
|
-
import { CalendarEvent, TimezoneName } from '../types/calendar.types';
|
|
3
|
+
import { CalendarEvent, RepeatingCalendarEvent, TimezoneName } from '../types/calendar.types';
|
|
4
4
|
declare const calendarUtil: {
|
|
5
5
|
freqMapToRRule: {
|
|
6
6
|
weekly: import("rrule").Frequency;
|
|
@@ -24,4 +24,3 @@ declare const calendarUtil: {
|
|
|
24
24
|
getEventFromRangeByDate(values: RepeatingCalendarEvent, date: number, timezone: TimezoneName): Pick<import("@sprucelabs/spruce-core-schemas").SpruceSchemas.CalendarUtils.v2021_05_19.CalendarEvent, "interval" | "startDateTimeMs" | "timeBlocks" | "repeats" | "daysOfWeek" | "daysOfMonth" | "repeatsUntil" | "occurrences" | "nthOccurrences" | "nthInRepeating" | "totalInRepeating"> | undefined;
|
|
25
25
|
};
|
|
26
26
|
export default calendarUtil;
|
|
27
|
-
export type RepeatingCalendarEvent = Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>;
|
package/build/locales/Locale.js
CHANGED
|
@@ -23,11 +23,13 @@ class LocaleImpl extends mercury_event_emitter_1.AbstractEventEmitter {
|
|
|
23
23
|
this.currentZone = undefined;
|
|
24
24
|
}
|
|
25
25
|
getTimezoneOffsetMinutes(onDate, timezone) {
|
|
26
|
-
if (onDate) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
26
|
+
if (onDate || timezone) {
|
|
27
|
+
const date = onDate ? onDate : Date.now();
|
|
28
|
+
const dateRoundedToNearestHour = date - (date % 3600000);
|
|
29
|
+
const zone = timezone !== null && timezone !== void 0 ? timezone : this.getZoneName();
|
|
30
|
+
const key = `${zone}-${dateRoundedToNearestHour}`;
|
|
29
31
|
if (!(key in this.offsetsForDate)) {
|
|
30
|
-
this.offsetsForDate[key] = this.zoneNameToOffsetMinutes(
|
|
32
|
+
this.offsetsForDate[key] = this.zoneNameToOffsetMinutes(zone, onDate);
|
|
31
33
|
}
|
|
32
34
|
return this.offsetsForDate[key];
|
|
33
35
|
}
|
|
@@ -22,4 +22,5 @@ export type SorterCalendarEvent = {
|
|
|
22
22
|
startDateTimeMs: number;
|
|
23
23
|
personId: string;
|
|
24
24
|
};
|
|
25
|
+
export type RepeatingCalendarEvent = Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>;
|
|
25
26
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RRule } from 'rrule';
|
|
2
2
|
import LocaleImpl from '../locales/Locale';
|
|
3
|
-
import { CalendarEvent, TimezoneName } from '../types/calendar.types';
|
|
3
|
+
import { CalendarEvent, RepeatingCalendarEvent, TimezoneName } from '../types/calendar.types';
|
|
4
4
|
declare const calendarUtil: {
|
|
5
5
|
freqMapToRRule: {
|
|
6
6
|
weekly: import("rrule").Frequency;
|
|
@@ -24,4 +24,3 @@ declare const calendarUtil: {
|
|
|
24
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;
|
|
27
|
-
export type RepeatingCalendarEvent = Pick<CalendarEvent, 'repeats' | 'repeatsUntil' | 'daysOfWeek' | 'daysOfMonth' | 'interval' | 'startDateTimeMs' | 'occurrences' | 'nthOccurrences' | 'timeBlocks' | 'nthInRepeating' | 'totalInRepeating'>;
|