@sprucelabs/calendar-utils 40.0.139 → 40.0.140
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.
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { TimezoneName } from '../types/calendar.types';
|
|
1
2
|
declare const durationUtil: {
|
|
2
3
|
dates: {
|
|
3
4
|
eventDaysOfWeek: {
|
|
4
5
|
sun: string;
|
|
5
6
|
mon: string;
|
|
6
|
-
tue: string;
|
|
7
|
-
* @deprecated durationUtil.msToFriendly(...) -> durationUtil.renderDuration(...)
|
|
8
|
-
*/
|
|
7
|
+
tue: string;
|
|
9
8
|
wed: string;
|
|
10
9
|
thur: string;
|
|
11
10
|
fri: string;
|
|
@@ -56,16 +55,17 @@ declare const durationUtil: {
|
|
|
56
55
|
/**
|
|
57
56
|
* @deprecated durationUtil.dateTimeUntilFriendly(...) -> durationUtil.renderDateTimeUntil(...)
|
|
58
57
|
*/
|
|
59
|
-
dateTimeUntilFriendly(start: number, prefixes?: Partial<
|
|
60
|
-
renderDateTimeUntil(
|
|
58
|
+
dateTimeUntilFriendly(start: number, prefixes?: Partial<TimeUntilOptions>): string;
|
|
59
|
+
renderDateTimeUntil(beginning: number, end: number, prefixes?: Partial<TimeUntilOptions>): string;
|
|
61
60
|
renderTimeRange(date1: number, date2: number): string;
|
|
62
61
|
};
|
|
63
62
|
export default durationUtil;
|
|
64
|
-
export interface
|
|
63
|
+
export interface TimeUntilOptions {
|
|
65
64
|
yesterday?: string | null;
|
|
66
65
|
today?: string | null;
|
|
67
66
|
tomorrow?: string | null;
|
|
68
67
|
future?: string | null;
|
|
69
68
|
past?: string | null;
|
|
70
69
|
shouldCapitalize?: boolean;
|
|
70
|
+
timezoneName?: TimezoneName;
|
|
71
71
|
}
|
|
@@ -38,11 +38,13 @@ const durationUtil = {
|
|
|
38
38
|
dateTimeUntilFriendly(start, prefixes) {
|
|
39
39
|
return this.renderDateTimeUntil(start, new Date().getTime(), prefixes);
|
|
40
40
|
},
|
|
41
|
-
renderDateTimeUntil(
|
|
41
|
+
renderDateTimeUntil(beginning, end, prefixes) {
|
|
42
42
|
const { today = null, tomorrow = null, yesterday = null, future = null, past = null, shouldCapitalize, } = prefixes !== null && prefixes !== void 0 ? prefixes : {};
|
|
43
43
|
let prefix = today;
|
|
44
44
|
let startDateAndTime = 'today';
|
|
45
|
-
const daysFromNow = Math.round((
|
|
45
|
+
const daysFromNow = Math.round((this.dates.getStartOfDay(beginning) -
|
|
46
|
+
this.dates.getStartOfDay(end)) /
|
|
47
|
+
(1000 * 3600 * 24));
|
|
46
48
|
if (daysFromNow === -1) {
|
|
47
49
|
prefix = yesterday;
|
|
48
50
|
startDateAndTime = 'yesterday';
|
|
@@ -54,15 +56,17 @@ const durationUtil = {
|
|
|
54
56
|
else if (daysFromNow > 1) {
|
|
55
57
|
prefix = future;
|
|
56
58
|
startDateAndTime =
|
|
57
|
-
this.dates.format(
|
|
59
|
+
this.dates.format(beginning, 'MMM do') +
|
|
60
|
+
` (in ${daysFromNow} days)`;
|
|
58
61
|
}
|
|
59
62
|
else if (daysFromNow < -1) {
|
|
60
63
|
prefix = past;
|
|
61
64
|
startDateAndTime =
|
|
62
|
-
this.dates.format(
|
|
65
|
+
this.dates.format(beginning, 'MMM do') +
|
|
63
66
|
` (${daysFromNow * -1} days ago)`;
|
|
64
67
|
}
|
|
65
|
-
startDateAndTime +=
|
|
68
|
+
startDateAndTime +=
|
|
69
|
+
` @ ${this.dates.format(beginning, 'h:mmaaa')}`.replace(':00', '');
|
|
66
70
|
return optionallUcFirst(`${prefix ? `${prefix} ` : ''}${startDateAndTime}`, shouldCapitalize);
|
|
67
71
|
},
|
|
68
72
|
renderTimeRange(date1, date2) {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { TimezoneName } from '../types/calendar.types';
|
|
1
2
|
declare const durationUtil: {
|
|
2
3
|
dates: {
|
|
3
4
|
eventDaysOfWeek: {
|
|
4
5
|
sun: string;
|
|
5
6
|
mon: string;
|
|
6
|
-
tue: string;
|
|
7
|
-
* @deprecated durationUtil.msToFriendly(...) -> durationUtil.renderDuration(...)
|
|
8
|
-
*/
|
|
7
|
+
tue: string;
|
|
9
8
|
wed: string;
|
|
10
9
|
thur: string;
|
|
11
10
|
fri: string;
|
|
@@ -56,16 +55,17 @@ declare const durationUtil: {
|
|
|
56
55
|
/**
|
|
57
56
|
* @deprecated durationUtil.dateTimeUntilFriendly(...) -> durationUtil.renderDateTimeUntil(...)
|
|
58
57
|
*/
|
|
59
|
-
dateTimeUntilFriendly(start: number, prefixes?: Partial<
|
|
60
|
-
renderDateTimeUntil(
|
|
58
|
+
dateTimeUntilFriendly(start: number, prefixes?: Partial<TimeUntilOptions>): string;
|
|
59
|
+
renderDateTimeUntil(beginning: number, end: number, prefixes?: Partial<TimeUntilOptions>): string;
|
|
61
60
|
renderTimeRange(date1: number, date2: number): string;
|
|
62
61
|
};
|
|
63
62
|
export default durationUtil;
|
|
64
|
-
export interface
|
|
63
|
+
export interface TimeUntilOptions {
|
|
65
64
|
yesterday?: string | null;
|
|
66
65
|
today?: string | null;
|
|
67
66
|
tomorrow?: string | null;
|
|
68
67
|
future?: string | null;
|
|
69
68
|
past?: string | null;
|
|
70
69
|
shouldCapitalize?: boolean;
|
|
70
|
+
timezoneName?: TimezoneName;
|
|
71
71
|
}
|
|
@@ -43,11 +43,13 @@ const durationUtil = {
|
|
|
43
43
|
dateTimeUntilFriendly(start, prefixes) {
|
|
44
44
|
return this.renderDateTimeUntil(start, new Date().getTime(), prefixes);
|
|
45
45
|
},
|
|
46
|
-
renderDateTimeUntil(
|
|
46
|
+
renderDateTimeUntil(beginning, end, prefixes) {
|
|
47
47
|
const { today = null, tomorrow = null, yesterday = null, future = null, past = null, shouldCapitalize, } = prefixes !== null && prefixes !== void 0 ? prefixes : {};
|
|
48
48
|
let prefix = today;
|
|
49
49
|
let startDateAndTime = 'today';
|
|
50
|
-
const daysFromNow = Math.round((
|
|
50
|
+
const daysFromNow = Math.round((this.dates.getStartOfDay(beginning) -
|
|
51
|
+
this.dates.getStartOfDay(end)) /
|
|
52
|
+
(1000 * 3600 * 24));
|
|
51
53
|
if (daysFromNow === -1) {
|
|
52
54
|
prefix = yesterday;
|
|
53
55
|
startDateAndTime = 'yesterday';
|
|
@@ -59,15 +61,17 @@ const durationUtil = {
|
|
|
59
61
|
else if (daysFromNow > 1) {
|
|
60
62
|
prefix = future;
|
|
61
63
|
startDateAndTime =
|
|
62
|
-
this.dates.format(
|
|
64
|
+
this.dates.format(beginning, 'MMM do') +
|
|
65
|
+
` (in ${daysFromNow} days)`;
|
|
63
66
|
}
|
|
64
67
|
else if (daysFromNow < -1) {
|
|
65
68
|
prefix = past;
|
|
66
69
|
startDateAndTime =
|
|
67
|
-
this.dates.format(
|
|
70
|
+
this.dates.format(beginning, 'MMM do') +
|
|
68
71
|
` (${daysFromNow * -1} days ago)`;
|
|
69
72
|
}
|
|
70
|
-
startDateAndTime +=
|
|
73
|
+
startDateAndTime +=
|
|
74
|
+
` @ ${this.dates.format(beginning, 'h:mmaaa')}`.replace(':00', '');
|
|
71
75
|
return optionallUcFirst(`${prefix ? `${prefix} ` : ''}${startDateAndTime}`, shouldCapitalize);
|
|
72
76
|
},
|
|
73
77
|
renderTimeRange(date1, date2) {
|