@sprucelabs/calendar-utils 41.1.13 → 42.0.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/utilities/DurationUtilBuilder.d.ts +2 -2
- package/build/esm/utilities/duration.utility.d.ts +3 -4
- package/build/esm/utilities/duration.utility.js +3 -4
- package/build/utilities/DurationUtilBuilder.d.ts +2 -2
- package/build/utilities/duration.utility.d.ts +3 -4
- package/build/utilities/duration.utility.js +3 -4
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ export default class DurationUtilBuilder {
|
|
|
49
49
|
getTotalDaysInMonth(year: number, month: number): number;
|
|
50
50
|
};
|
|
51
51
|
renderDuration(durationMs: number): string;
|
|
52
|
-
renderDateTimeUntil(
|
|
52
|
+
renderDateTimeUntil(end: number, prefixes?: Partial<import("./duration.utility").TimeUntilOptions>): string;
|
|
53
53
|
renderTimeRange(date1: number, date2: number): string;
|
|
54
54
|
};
|
|
55
55
|
static lastBuiltDurationUtil?: DurationUtil;
|
|
@@ -102,7 +102,7 @@ export default class DurationUtilBuilder {
|
|
|
102
102
|
getTotalDaysInMonth(year: number, month: number): number;
|
|
103
103
|
};
|
|
104
104
|
renderDuration(durationMs: number): string;
|
|
105
|
-
renderDateTimeUntil(
|
|
105
|
+
renderDateTimeUntil(end: number, prefixes?: Partial<import("./duration.utility").TimeUntilOptions>): string;
|
|
106
106
|
renderTimeRange(date1: number, date2: number): string;
|
|
107
107
|
}>;
|
|
108
108
|
static reset(): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TimezoneName } from '../types/calendar.types';
|
|
2
1
|
declare const durationUtil: {
|
|
3
2
|
dates: {
|
|
4
3
|
eventDaysOfWeek: {
|
|
@@ -25,7 +24,7 @@ declare const durationUtil: {
|
|
|
25
24
|
getDurationMs(timestamp: number, endTimestamp: number): number;
|
|
26
25
|
getDurationMinutes(timestamp: number, endTimestamp: number): number;
|
|
27
26
|
getDurationDays(timestamp: number, endTimestamp: number): number;
|
|
28
|
-
getDayOfWeek(timestamp: number): import("
|
|
27
|
+
getDayOfWeek(timestamp: number): import("..").DayOfWeek;
|
|
29
28
|
getDayOfWeekIndex(timestamp: number): number;
|
|
30
29
|
splitDate(timestamp: number): {
|
|
31
30
|
year: number;
|
|
@@ -48,7 +47,7 @@ declare const durationUtil: {
|
|
|
48
47
|
getTotalDaysInMonth(year: number, month: number): number;
|
|
49
48
|
};
|
|
50
49
|
renderDuration(durationMs: number): string;
|
|
51
|
-
renderDateTimeUntil(
|
|
50
|
+
renderDateTimeUntil(end: number, prefixes?: Partial<TimeUntilOptions>): string;
|
|
52
51
|
renderTimeRange(date1: number, date2: number): string;
|
|
53
52
|
};
|
|
54
53
|
export default durationUtil;
|
|
@@ -59,5 +58,5 @@ export interface TimeUntilOptions {
|
|
|
59
58
|
future?: string | null;
|
|
60
59
|
past?: string | null;
|
|
61
60
|
shouldCapitalize?: boolean;
|
|
62
|
-
|
|
61
|
+
now?: number;
|
|
63
62
|
}
|
|
@@ -26,12 +26,11 @@ const durationUtil = {
|
|
|
26
26
|
}
|
|
27
27
|
return durationStr.trim();
|
|
28
28
|
},
|
|
29
|
-
renderDateTimeUntil(
|
|
30
|
-
const { today = null, tomorrow = null, yesterday = null, future = null, past = null, shouldCapitalize, } = prefixes !== null && prefixes !== void 0 ? prefixes : {};
|
|
29
|
+
renderDateTimeUntil(end, prefixes) {
|
|
30
|
+
const { today = null, tomorrow = null, yesterday = null, future = null, past = null, shouldCapitalize, now = Date.now(), } = prefixes !== null && prefixes !== void 0 ? prefixes : {};
|
|
31
31
|
let prefix = today;
|
|
32
32
|
let startDateAndTime = 'today';
|
|
33
|
-
const daysFromNow = Math.round((this.dates.getStartOfDay(end) -
|
|
34
|
-
this.dates.getStartOfDay(beginning)) /
|
|
33
|
+
const daysFromNow = Math.round((this.dates.getStartOfDay(end) - this.dates.getStartOfDay(now)) /
|
|
35
34
|
(1000 * 3600 * 24));
|
|
36
35
|
if (daysFromNow === -1) {
|
|
37
36
|
prefix = yesterday;
|
|
@@ -49,7 +49,7 @@ export default class DurationUtilBuilder {
|
|
|
49
49
|
getTotalDaysInMonth(year: number, month: number): number;
|
|
50
50
|
};
|
|
51
51
|
renderDuration(durationMs: number): string;
|
|
52
|
-
renderDateTimeUntil(
|
|
52
|
+
renderDateTimeUntil(end: number, prefixes?: Partial<import("./duration.utility").TimeUntilOptions>): string;
|
|
53
53
|
renderTimeRange(date1: number, date2: number): string;
|
|
54
54
|
};
|
|
55
55
|
static lastBuiltDurationUtil?: DurationUtil;
|
|
@@ -102,7 +102,7 @@ export default class DurationUtilBuilder {
|
|
|
102
102
|
getTotalDaysInMonth(year: number, month: number): number;
|
|
103
103
|
};
|
|
104
104
|
renderDuration(durationMs: number): string;
|
|
105
|
-
renderDateTimeUntil(
|
|
105
|
+
renderDateTimeUntil(end: number, prefixes?: Partial<import("./duration.utility").TimeUntilOptions>): string;
|
|
106
106
|
renderTimeRange(date1: number, date2: number): string;
|
|
107
107
|
}>;
|
|
108
108
|
static reset(): void;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TimezoneName } from '../types/calendar.types';
|
|
2
1
|
declare const durationUtil: {
|
|
3
2
|
dates: {
|
|
4
3
|
eventDaysOfWeek: {
|
|
@@ -25,7 +24,7 @@ declare const durationUtil: {
|
|
|
25
24
|
getDurationMs(timestamp: number, endTimestamp: number): number;
|
|
26
25
|
getDurationMinutes(timestamp: number, endTimestamp: number): number;
|
|
27
26
|
getDurationDays(timestamp: number, endTimestamp: number): number;
|
|
28
|
-
getDayOfWeek(timestamp: number): import("
|
|
27
|
+
getDayOfWeek(timestamp: number): import("..").DayOfWeek;
|
|
29
28
|
getDayOfWeekIndex(timestamp: number): number;
|
|
30
29
|
splitDate(timestamp: number): {
|
|
31
30
|
year: number;
|
|
@@ -48,7 +47,7 @@ declare const durationUtil: {
|
|
|
48
47
|
getTotalDaysInMonth(year: number, month: number): number;
|
|
49
48
|
};
|
|
50
49
|
renderDuration(durationMs: number): string;
|
|
51
|
-
renderDateTimeUntil(
|
|
50
|
+
renderDateTimeUntil(end: number, prefixes?: Partial<TimeUntilOptions>): string;
|
|
52
51
|
renderTimeRange(date1: number, date2: number): string;
|
|
53
52
|
};
|
|
54
53
|
export default durationUtil;
|
|
@@ -59,5 +58,5 @@ export interface TimeUntilOptions {
|
|
|
59
58
|
future?: string | null;
|
|
60
59
|
past?: string | null;
|
|
61
60
|
shouldCapitalize?: boolean;
|
|
62
|
-
|
|
61
|
+
now?: number;
|
|
63
62
|
}
|
|
@@ -31,12 +31,11 @@ const durationUtil = {
|
|
|
31
31
|
}
|
|
32
32
|
return durationStr.trim();
|
|
33
33
|
},
|
|
34
|
-
renderDateTimeUntil(
|
|
35
|
-
const { today = null, tomorrow = null, yesterday = null, future = null, past = null, shouldCapitalize, } = prefixes !== null && prefixes !== void 0 ? prefixes : {};
|
|
34
|
+
renderDateTimeUntil(end, prefixes) {
|
|
35
|
+
const { today = null, tomorrow = null, yesterday = null, future = null, past = null, shouldCapitalize, now = Date.now(), } = prefixes !== null && prefixes !== void 0 ? prefixes : {};
|
|
36
36
|
let prefix = today;
|
|
37
37
|
let startDateAndTime = 'today';
|
|
38
|
-
const daysFromNow = Math.round((this.dates.getStartOfDay(end) -
|
|
39
|
-
this.dates.getStartOfDay(beginning)) /
|
|
38
|
+
const daysFromNow = Math.round((this.dates.getStartOfDay(end) - this.dates.getStartOfDay(now)) /
|
|
40
39
|
(1000 * 3600 * 24));
|
|
41
40
|
if (daysFromNow === -1) {
|
|
42
41
|
prefix = yesterday;
|