@bash-app/bash-common 29.44.1 → 29.44.3
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/package.json +1 -1
- package/src/definitions.ts +2 -0
- package/src/utils/dateTimeUtils.ts +15 -16
package/package.json
CHANGED
package/src/definitions.ts
CHANGED
|
@@ -64,6 +64,8 @@ export const URL_PARAMS_REDIRECT = 'redirect' as const;
|
|
|
64
64
|
export const URL_PARAMS_GOOGLE_ACCESS_CODE = 'code' as const;
|
|
65
65
|
export const URL_PARAMS_LINKED_IN_CODE = 'code' as const;
|
|
66
66
|
export const URL_PARAMS_STATE = 'state' as const;
|
|
67
|
+
export const URL_PARAMS_STRIPE_CHECKOUT = 'checkout' as const;
|
|
68
|
+
export type UrlParamsStripeCheckoutOptions = 'complete' | 'incomplete';
|
|
67
69
|
|
|
68
70
|
export const URL_PARAMS_TICKET_LIST_DELIM = ',' as const;
|
|
69
71
|
export const URL_PARAMS_TICKET_TIER_ID_NUMBER_OF_TICKETS_DATE_DELIM = '__' as const
|
|
@@ -19,7 +19,7 @@ export const TIME_FORMAT_AM_PM = "h:mm A";
|
|
|
19
19
|
export interface ITime {
|
|
20
20
|
hours: number;
|
|
21
21
|
minutes: number;
|
|
22
|
-
ampm:
|
|
22
|
+
ampm: 'AM' | 'PM';
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function formatDateRange(startDateTimeArg: Date | null, endDateTimeArg: Date | null): string {
|
|
@@ -42,21 +42,16 @@ export function ensureIsDateTime(possiblyADate: DateTimeArgType): Date | undefin
|
|
|
42
42
|
export function normalizeDate(validDate: Date | string | undefined | null): Date | undefined {
|
|
43
43
|
if (!validDate) return undefined;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
const date = typeof validDate === "string" ? new Date(validDate) : validDate;
|
|
45
|
+
const date = new Date(validDate);
|
|
47
46
|
|
|
48
|
-
// Check if the date is valid
|
|
49
47
|
if (isNaN(date.getTime())) {
|
|
50
48
|
console.error("Invalid date provided:", validDate);
|
|
51
49
|
return undefined;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return normalizedDate;
|
|
52
|
+
// Normalize to UTC and start of minute
|
|
53
|
+
return dayjs(date).utc().startOf("minute").toDate();
|
|
58
54
|
}
|
|
59
|
-
|
|
60
55
|
export function normalizeDates(dates: (Date | string | undefined | null)[]): Date[] {
|
|
61
56
|
return dates
|
|
62
57
|
.map((date) => normalizeDate(date)) // Normalize each date
|
|
@@ -178,12 +173,16 @@ export function setDateButPreserveTime(
|
|
|
178
173
|
}
|
|
179
174
|
|
|
180
175
|
|
|
181
|
-
export function setTimeOnDate(date: DateType | Date | undefined, parsedTime: ITime): Date {
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
176
|
+
export function setTimeOnDate(date: DateType | Date | undefined, parsedTime: ITime | null): Date {
|
|
177
|
+
const isValidDate = dayjs(date).isValid();
|
|
178
|
+
const dateTime = new Date(isValidDate && date ? date : Date.now());
|
|
179
|
+
if (parsedTime) {
|
|
180
|
+
const parsedTimeDate = new Date();
|
|
181
|
+
parsedTimeDate.setHours(parsedTime.hours, parsedTime.minutes, 0); // Will change the date depending on time; corrected later
|
|
182
|
+
const correctTimeOnDate = setDateButPreserveTime(dateTime, parsedTimeDate);
|
|
183
|
+
return correctTimeOnDate;
|
|
184
|
+
}
|
|
185
|
+
return dateTime;
|
|
187
186
|
}
|
|
188
187
|
|
|
189
188
|
export function ensureDateTimeIsLocalDateTime(dateArg: DateType | Dayjs | undefined): Dayjs {
|
|
@@ -232,4 +231,4 @@ export function localDateToUTC(date: Date): Date {
|
|
|
232
231
|
date.getUTCMinutes(), date.getUTCSeconds());
|
|
233
232
|
|
|
234
233
|
return newDate;
|
|
235
|
-
}
|
|
234
|
+
}
|