@bash-app/bash-common 29.66.0 → 29.67.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bash-app/bash-common",
3
- "version": "29.66.0",
3
+ "version": "29.67.0",
4
4
  "description": "Common data and scripts to use on the frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -191,7 +191,8 @@ model BashEvent {
191
191
  title String
192
192
  creatorId String
193
193
  creator User @relation("CreatedEvent", fields: [creatorId], references: [id], onDelete: Cascade)
194
- isApproved Boolean?
194
+ createdAt DateTime @default(now())
195
+ isApproved Boolean? @default(false)
195
196
  description String?
196
197
  eventType String @default("Other")
197
198
  startDateTime DateTime? @default(now())
@@ -244,7 +245,6 @@ model BashEvent {
244
245
  venue Venue? @relation(fields: [venueId], references: [id])
245
246
  userPromoCodeRedemption UserPromoCodeRedemption[]
246
247
  averageRating Float? @default(0)
247
- createdAt DateTime @default(now()) // Timestamp for when the review was created
248
248
  }
249
249
 
250
250
  model Coordinates {
@@ -612,11 +612,17 @@ enum Education {
612
612
  NoPreference
613
613
  }
614
614
 
615
+ enum UserIntent {
616
+ EventSeeker
617
+ EventOrganizer
618
+ VenueOwner
619
+ }
620
+
615
621
  enum BashStatus {
616
622
  Draft
623
+ Pending
617
624
  PreSale
618
625
  Published
619
- Pending
620
626
  Finished
621
627
  }
622
628
 
@@ -856,6 +862,7 @@ model User {
856
862
  stripeAccountId String? @unique
857
863
  isSuperUser Boolean @default(false)
858
864
  // isSuspended Boolean @default(false)
865
+ intent UserIntent?
859
866
  googleCalendarAccess String?
860
867
  givenName String?
861
868
  familyName String?
@@ -1517,8 +1524,8 @@ model ServiceRate {
1517
1524
  // if isAvailable is false it is closed
1518
1525
  model ServiceSpecialRates {
1519
1526
  id String @id @default(cuid())
1520
- startDate DateTime @db.Date
1521
- endDate DateTime @db.Date
1527
+ startDate DateTime //needs to be DateTime and not just Date because of timezone conversions
1528
+ endDate DateTime
1522
1529
 
1523
1530
  serviceRateId String?
1524
1531
  serviceRate ServiceRate? @relation(fields: [serviceRateId], references: [id], onDelete: Cascade)
@@ -1535,10 +1542,11 @@ model ServiceSpecialRates {
1535
1542
  // can have special rates on different days of the year (single or range)
1536
1543
  // free trial period with promo code (1 or 2 months of listing for free)
1537
1544
  model ServiceDailyRates {
1538
- id String @id @default(cuid())
1539
- dayOfWeek DayOfWeek
1540
- startTime DateTime @db.Time
1541
- endTime DateTime @db.Time
1545
+ id String @id @default(cuid())
1546
+ startDayOfWeek DayOfWeek
1547
+ startTime DateTime @db.Time
1548
+ endDayOfWeek DayOfWeek
1549
+ endTime DateTime @db.Time
1542
1550
 
1543
1551
  serviceRateId String?
1544
1552
  serviceRate ServiceRate? @relation(fields: [serviceRateId], references: [id], onDelete: Cascade)
@@ -302,6 +302,7 @@ export interface ApiResult<T, P extends ErrorDataType = ErrorDataType> {
302
302
  error?: string;
303
303
  errorType?: ApiErrorType;
304
304
  errorData?: P;
305
+ rawResponse?: any;
305
306
  }
306
307
 
307
308
  export enum ApiErrorType {
@@ -489,6 +490,7 @@ export interface IMediaUploadArgs {
489
490
  mimetype: string;
490
491
  idOfLinkedPrismaEntry: string;
491
492
  assetKey: string;
493
+ fileBuffer?: Buffer;
492
494
  }
493
495
 
494
496
  export interface IPreSignedUrlArgs {
@@ -535,6 +537,8 @@ export const DressTagsToString: { [key in BashEventDressTags]: string } = {
535
537
  // [ServicesTags.AwardRecipient]: "Award recipient"
536
538
  // }
537
539
 
540
+ export type DayOfWeekIdx = 1 | 2 | 3 | 4 | 5 | 6 | 7;
541
+
538
542
  export const DayOfWeekToString: { [key in DayOfWeek]: string } = {
539
543
  [DayOfWeek.Sunday]: "S",
540
544
  [DayOfWeek.Monday]: "M",
@@ -545,6 +549,16 @@ export const DayOfWeekToString: { [key in DayOfWeek]: string } = {
545
549
  [DayOfWeek.Saturday]: "S",
546
550
  };
547
551
 
552
+ export const DayOfWeekToIdx: { [key in DayOfWeek]: DayOfWeekIdx } = {
553
+ [DayOfWeek.Sunday]: 1,
554
+ [DayOfWeek.Monday]: 2,
555
+ [DayOfWeek.Tuesday]: 3,
556
+ [DayOfWeek.Wednesday]: 4,
557
+ [DayOfWeek.Thursday]: 5,
558
+ [DayOfWeek.Friday]: 6,
559
+ [DayOfWeek.Saturday]: 7,
560
+ };
561
+
548
562
  export const YearsOfExperienceToString: { [key in YearsOfExperience]: string } =
549
563
  {
550
564
  [YearsOfExperience.LessThanOneYear]: "Less than one year",
@@ -43,13 +43,13 @@ import {
43
43
  ServiceRatesAssociation,
44
44
  ServiceRate,
45
45
  ServiceDailyRates,
46
- ServiceSpecialRates,
47
46
  ServiceAddon,
48
47
  ServicePackage,
49
48
  UserSubscription,
50
49
  SocialMediaProfile,
51
50
  SocialMediaPlatform,
52
51
  ServiceSubscriptionCounts,
52
+ ServiceSpecialRates,
53
53
  } from "@prisma/client";
54
54
  import { SERVICE_LINK_DATA_TO_INCLUDE, UnionFromArray } from "./definitions";
55
55
 
@@ -100,10 +100,10 @@ export const FRONT_END_USER_DATA_TO_SELECT = {
100
100
  // documentID: true,
101
101
  reviews: true,
102
102
  contacts: true,
103
- accepted: true,
104
- boughtTicket: true,
105
- noPay: true,
106
- supportedEvent: true,
103
+ accepted: true,
104
+ boughtTicket: true,
105
+ noPay: true,
106
+ supportedEvent: true,
107
107
  } satisfies Prisma.UserSelect;
108
108
 
109
109
  export const PRIVATE_USER_ACCOUNT_TO_SELECT = {
@@ -508,7 +508,7 @@ export const EVENT_TASK_DATA_TO_INCLUDE = {
508
508
  export interface InvitationExt extends Invitation {
509
509
  creator: PublicUser; // Include full details of the creator
510
510
  sentTo?: PublicUser; // Full details of the user the invitation was sent to
511
- associatedBash?: Partial<AssociatedBashExt> | null
511
+ associatedBash?: Partial<AssociatedBashExt> | null;
512
512
  tickets: Ticket[]; // Tickets associated with the invitation
513
513
  }
514
514
 
package/src/index.ts CHANGED
@@ -17,3 +17,4 @@ export * from "./utils/service/serviceUtils";
17
17
  export * from "./utils/service/venueUtils";
18
18
  export * from "./utils/stripeAccountUtils";
19
19
  export * from "./utils/entityUtils";
20
+ // export * from "./utils/luxonUtils";
@@ -1,17 +1,16 @@
1
- import {DateType, DateValueType} from "react-tailwindcss-datepicker";
2
- import dayjs, {Dayjs} from "dayjs";
1
+ import { DateType, DateValueType } from "react-tailwindcss-datepicker";
2
+ import dayjs, { Dayjs } from "dayjs";
3
3
  import dayjsUtc from "dayjs/plugin/utc";
4
4
  import dayjsTimeZone from "dayjs/plugin/timezone";
5
- import {DateTimeArgType} from "../definitions";
5
+ import { DateTimeArgType } from "../definitions";
6
6
 
7
7
  dayjs.extend(dayjsUtc);
8
8
  dayjs.extend(dayjsTimeZone);
9
9
 
10
-
11
10
  const PARSE_TIME_REG = /^(\d{1,2}):(\d{2}) ?([APM]{0,2})$/i;
12
11
 
13
12
  export const DATETIME_FORMAT_STANDARD = "MMM D, YYYY - h:mm A";
14
- export const DATETIME_FORMAT_ISO_LIKE = "YYYY-MM-DD HH:mm"
13
+ export const DATETIME_FORMAT_ISO_LIKE = "YYYY-MM-DD HH:mm";
15
14
  export const DATE_FORMAT_STANDARD = "MM/DD/YYYY";
16
15
  export const DATE_FORMAT_ISO = "YYYY-MM-DD";
17
16
  export const TIME_FORMAT_AM_PM = "h:mm A";
@@ -19,27 +18,62 @@ export const TIME_FORMAT_AM_PM = "h:mm A";
19
18
  export interface ITime {
20
19
  hours: number;
21
20
  minutes: number;
22
- ampm: 'AM' | 'PM';
21
+ ampm: "AM" | "PM";
23
22
  }
24
23
 
25
- export function formatDateRange(startDateTimeArg: Date | null, endDateTimeArg: Date | null): string {
26
- const startDateTime = ensureDateTimeIsLocalDateTime(startDateTimeArg).tz(dayjs.tz.guess());
27
- const endDateTime = ensureDateTimeIsLocalDateTime(endDateTimeArg).tz(dayjs.tz.guess());
28
- if (startDateTime.isSame(endDateTime, 'day')) {
29
- return `${startDateTime.format(DATETIME_FORMAT_STANDARD)} to ${endDateTime.format(TIME_FORMAT_AM_PM)}`;
24
+ export function formatDateRangeBasic(
25
+ startDateTimeArg: Date | null,
26
+ endDateTimeArg: Date | null
27
+ ): string {
28
+ const startDateTime = dayjs(startDateTimeArg).tz(dayjs.tz.guess());
29
+ const endDateTime = dayjs(endDateTimeArg).tz(dayjs.tz.guess());
30
+ if (startDateTime.isSame(endDateTime, "day")) {
31
+ return `${startDateTime.format(
32
+ DATETIME_FORMAT_STANDARD
33
+ )} to ${endDateTime.format(TIME_FORMAT_AM_PM)}`;
30
34
  }
31
35
 
32
- return `${startDateTime.format(DATETIME_FORMAT_STANDARD)} to ${endDateTime.format(DATETIME_FORMAT_STANDARD)}`;
36
+ return `${startDateTime.format(
37
+ DATETIME_FORMAT_STANDARD
38
+ )} to ${endDateTime.format(DATETIME_FORMAT_STANDARD)}`;
33
39
  }
34
40
 
35
- export function ensureIsDateTime(possiblyADate: DateTimeArgType): Date | undefined {
41
+ export function formatDateRange(
42
+ startDateTimeArg: Date | null,
43
+ endDateTimeArg: Date | null
44
+ ): string {
45
+ const startDateTime = ensureDateTimeIsLocalDateTime(startDateTimeArg).tz(
46
+ dayjs.tz.guess()
47
+ );
48
+ const endDateTime = ensureDateTimeIsLocalDateTime(endDateTimeArg).tz(
49
+ dayjs.tz.guess()
50
+ );
51
+ if (startDateTime.isSame(endDateTime, "day")) {
52
+ return `${startDateTime.format(
53
+ DATETIME_FORMAT_STANDARD
54
+ )} to ${endDateTime.format(TIME_FORMAT_AM_PM)}`;
55
+ }
56
+
57
+ return `${startDateTime.format(
58
+ DATETIME_FORMAT_STANDARD
59
+ )} to ${endDateTime.format(DATETIME_FORMAT_STANDARD)}`;
60
+ }
61
+
62
+ export function ensureIsDateTime(
63
+ possiblyADate: DateTimeArgType
64
+ ): Date | undefined {
36
65
  if (!possiblyADate) {
37
66
  return undefined;
38
67
  }
39
- return typeof possiblyADate === 'string' ? new Date(possiblyADate) : possiblyADate;
68
+ return typeof possiblyADate === "string"
69
+ ? new Date(possiblyADate)
70
+ : possiblyADate;
40
71
  }
41
72
 
42
- export function normalizeDate(validDate: Date | string | undefined | null): Date | undefined {
73
+ //convert to utc and round minutes
74
+ export function normalizeDate(
75
+ validDate: Date | string | undefined | null
76
+ ): Date | undefined {
43
77
  if (!validDate) return undefined;
44
78
 
45
79
  const date = new Date(validDate);
@@ -52,14 +86,17 @@ export function normalizeDate(validDate: Date | string | undefined | null): Date
52
86
  // Normalize to UTC and start of minute
53
87
  return dayjs(date).utc().startOf("minute").toDate();
54
88
  }
55
- export function normalizeDates(dates: (Date | string | undefined | null)[]): Date[] {
89
+ export function normalizeDates(
90
+ dates: (Date | string | undefined | null)[]
91
+ ): Date[] {
56
92
  return dates
57
93
  .map((date) => normalizeDate(date)) // Normalize each date
58
94
  .filter((date): date is Date => !!date); // Filter out invalid dates
59
95
  }
60
96
 
61
-
62
- export function formatDateTimeToISODateTimeString(date: DateTimeArgType): string | undefined {
97
+ export function formatDateTimeToISODateTimeString(
98
+ date: DateTimeArgType
99
+ ): string | undefined {
63
100
  if (!date) {
64
101
  return undefined;
65
102
  }
@@ -67,25 +104,31 @@ export function formatDateTimeToISODateTimeString(date: DateTimeArgType): string
67
104
  return date.toISOString();
68
105
  }
69
106
 
70
- export function dateWithinDateRange(date: DateTimeArgType, dateRange: DateValueType | undefined): boolean {
71
- const startDate = dayjs(dateRange?.startDate).startOf('day').toDate();
72
- const endDate = dayjs(dateRange?.endDate).endOf('day').toDate();
107
+ export function dateWithinDateRange(
108
+ date: DateTimeArgType,
109
+ dateRange: DateValueType | undefined
110
+ ): boolean {
111
+ const startDate = dayjs(dateRange?.startDate).startOf("day").toDate();
112
+ const endDate = dayjs(dateRange?.endDate).endOf("day").toDate();
73
113
 
74
- return compareDateTime(date, startDate) >= 0 &&
75
- compareDateTime(date, endDate) < 0;
114
+ return (
115
+ compareDateTime(date, startDate) >= 0 && compareDateTime(date, endDate) < 0
116
+ );
76
117
  }
77
118
 
78
- export function findLatestDateTime(date1Arg: DateTimeArgType, date2Arg: DateTimeArgType): Date | undefined {
119
+ export function findLatestDateTime(
120
+ date1Arg: DateTimeArgType,
121
+ date2Arg: DateTimeArgType
122
+ ): Date | undefined {
79
123
  const date1 = dateTimeTypeToDate(date1Arg);
80
124
  const date2 = dateTimeTypeToDate(date2Arg);
81
125
  return compareDateTime(date1, date2) > 0 ? date1 : date2;
82
126
  }
83
127
 
84
128
  function dateTimeTypeToDate(date: DateTimeArgType): Date | undefined {
85
- if (typeof date === 'string') {
129
+ if (typeof date === "string") {
86
130
  return new Date(date);
87
- }
88
- else {
131
+ } else {
89
132
  return date ?? undefined;
90
133
  }
91
134
  }
@@ -94,8 +137,10 @@ export function isDateTimeLaterThanNow(date: DateTimeArgType): boolean {
94
137
  return compareDateTime(date, new Date()) > 0;
95
138
  }
96
139
 
97
- export function areDateTimesEqual(date1: DateTimeArgType,
98
- date2: DateTimeArgType): boolean {
140
+ export function areDateTimesEqual(
141
+ date1: DateTimeArgType,
142
+ date2: DateTimeArgType
143
+ ): boolean {
99
144
  return compareDateTime(date1, date2) === 0;
100
145
  }
101
146
 
@@ -104,8 +149,10 @@ export function areDateTimesEqual(date1: DateTimeArgType,
104
149
  * @param date1
105
150
  * @param date2
106
151
  */
107
- export function compareDateTime(date1: DateTimeArgType,
108
- date2: DateTimeArgType): number {
152
+ export function compareDateTime(
153
+ date1: DateTimeArgType,
154
+ date2: DateTimeArgType
155
+ ): number {
109
156
  if (!date1 && !date2) {
110
157
  return 0;
111
158
  }
@@ -115,10 +162,10 @@ export function compareDateTime(date1: DateTimeArgType,
115
162
  if (!date2) {
116
163
  return 1;
117
164
  }
118
- if (typeof date1 === 'string') {
165
+ if (typeof date1 === "string") {
119
166
  date1 = new Date(date1);
120
167
  }
121
- if (typeof date2 === 'string') {
168
+ if (typeof date2 === "string") {
122
169
  date2 = new Date(date2);
123
170
  }
124
171
 
@@ -130,8 +177,7 @@ export function compareDateTime(date1: DateTimeArgType,
130
177
  }
131
178
  if (date1Time === date2Time) {
132
179
  return 0;
133
- }
134
- else {
180
+ } else {
135
181
  return -1;
136
182
  }
137
183
  }
@@ -141,8 +187,13 @@ export function setDateButPreserveTime(
141
187
  dateWithTheTimeYouWantToKeep: DateType | undefined
142
188
  ): Date {
143
189
  if (!dateArg || !dateWithTheTimeYouWantToKeep) {
144
- console.error("Invalid arguments:", { dateArg, dateWithTheTimeYouWantToKeep });
145
- throw new Error("Both dateArg and dateWithTheTimeYouWantToKeep are required.");
190
+ console.error("Invalid arguments:", {
191
+ dateArg,
192
+ dateWithTheTimeYouWantToKeep,
193
+ });
194
+ throw new Error(
195
+ "Both dateArg and dateWithTheTimeYouWantToKeep are required."
196
+ );
146
197
  }
147
198
 
148
199
  // Get local timezone
@@ -150,7 +201,9 @@ export function setDateButPreserveTime(
150
201
 
151
202
  // Format date and time parts
152
203
  const datePart = dayjs(dateArg).tz(localTimeZone).format("YYYY-MM-DD"); // Local date
153
- const timePart = dayjs(dateWithTheTimeYouWantToKeep).tz(localTimeZone).format("HH:mm"); // Local time
204
+ const timePart = dayjs(dateWithTheTimeYouWantToKeep)
205
+ .tz(localTimeZone)
206
+ .format("HH:mm"); // Local time
154
207
 
155
208
  // Combine into an ISO string
156
209
  const combinedDateTimeString = `${datePart}T${timePart}`;
@@ -162,7 +215,9 @@ export function setDateButPreserveTime(
162
215
  });
163
216
 
164
217
  // Convert to UTC
165
- const combinedDateTime = dayjs.tz(combinedDateTimeString, localTimeZone).toDate();
218
+ const combinedDateTime = dayjs
219
+ .tz(combinedDateTimeString, localTimeZone)
220
+ .toDate();
166
221
  if (isNaN(combinedDateTime.getTime())) {
167
222
  console.error("Invalid combined datetime:", combinedDateTimeString);
168
223
  throw new Error("Invalid date or time format.");
@@ -172,8 +227,10 @@ export function setDateButPreserveTime(
172
227
  return combinedDateTime;
173
228
  }
174
229
 
175
-
176
- export function setTimeOnDate(date: DateType | Date | undefined, parsedTime: ITime | null): Date {
230
+ export function setTimeOnDate(
231
+ date: DateType | Date | undefined,
232
+ parsedTime: ITime | null
233
+ ): Date {
177
234
  const isValidDate = dayjs(date).isValid();
178
235
  const dateTime = new Date(isValidDate && date ? date : Date.now());
179
236
  if (parsedTime) {
@@ -185,23 +242,28 @@ export function setTimeOnDate(date: DateType | Date | undefined, parsedTime: ITi
185
242
  return dateTime;
186
243
  }
187
244
 
188
- export function ensureDateTimeIsLocalDateTime(dateArg: DateType | Dayjs | undefined): Dayjs {
245
+ export function ensureDateTimeIsLocalDateTime(
246
+ dateArg: DateType | Dayjs | undefined
247
+ ): Dayjs {
189
248
  if (dayjs(dateArg).isUTC()) {
190
249
  const dateLocalTimeZone = dayjs(dateArg);
191
250
  return dateLocalTimeZone;
192
- }
193
- else {
251
+ } else {
194
252
  return dayjs(dateArg ?? Date.now());
195
253
  }
196
254
  }
197
255
 
198
- export function formatDateTimeToTimeString(date: Date | string | undefined | null): string {
256
+ export function formatDateTimeToTimeString(
257
+ date: Date | string | undefined | null
258
+ ): string {
199
259
  date = new Date(date ?? Date.now());
200
260
  const result = dayjs(date).format("h:mm A");
201
261
  return result;
202
262
  }
203
263
 
204
- export function formatDateTimeToTimeString24hr(date: Date | string | undefined | null): string {
264
+ export function formatDateTimeToTimeString24hr(
265
+ date: Date | string | undefined | null
266
+ ): string {
205
267
  date = new Date(date ?? Date.now());
206
268
  const result = dayjs(date).format("h:mm");
207
269
  return result;
@@ -215,24 +277,22 @@ export function parseTimeString(timeStr: string): ITime | null {
215
277
  const minutes = parseInt(match[2], 10);
216
278
  const ampm = match[3].toUpperCase();
217
279
 
218
- if ((hours >= 0 && hours <= 12) && (minutes >= 0 && minutes <= 59) && (ampm === 'AM' || ampm === 'PM')) {
280
+ if (
281
+ hours >= 0 &&
282
+ hours <= 12 &&
283
+ minutes >= 0 &&
284
+ minutes <= 59 &&
285
+ (ampm === "AM" || ampm === "PM")
286
+ ) {
219
287
  return {
220
- hours: ampm === 'PM' && hours < 12 ? hours + 12 : hours,
288
+ hours: ampm === "PM" && hours < 12 ? hours + 12 : hours,
221
289
  minutes,
222
- ampm };
290
+ ampm,
291
+ };
223
292
  }
224
293
  }
225
294
  return null;
226
295
  }
227
-
228
- export function localDateToUTC(date: Date): Date {
229
- const newDate = new Date(date.getUTCFullYear(), date.getUTCMonth(),
230
- date.getUTCDate(), date.getUTCHours(),
231
- date.getUTCMinutes(), date.getUTCSeconds());
232
-
233
- return newDate;
296
+ export function timestampMinutesFromNow(minutes: number): number {
297
+ return Math.floor(new Date().getTime() / 1000 + minutes * 60);
234
298
  }
235
-
236
- export function timestampMinutseFromNow(minutes: number): number {
237
- return Math.floor((new Date().getTime() / 1000) + (minutes * 60));
238
- }
@@ -1,86 +0,0 @@
1
- // import { DayOfWeek } from "@prisma/client";
2
- // import { DateTime, Interval } from "luxon";
3
- // import { DayOfWeekIdx, DayOfWeekToIdx } from "../definitions";
4
-
5
- // export function dayOfWeekToIdx(dayOfWeek: DayOfWeek | DayOfWeekIdx): number {
6
- // if (typeof dayOfWeek === "number") {
7
- // return dayOfWeek;
8
- // } else if (typeof dayOfWeek === "string") {
9
- // return DayOfWeekToIdx[dayOfWeek];
10
- // } else {
11
- // throw new Error(`dayOfWeekToIdx: unhandled case`);
12
- // }
13
- // }
14
-
15
- // export function dateTimeFromDayTime(
16
- // dayOfWeek: DayOfWeek | DayOfWeekIdx,
17
- // hour: number = 0,
18
- // minute: number = 0
19
- // ): DateTime {
20
- // //use date where first day of month is a known sunday
21
- // return DateTime.fromObject({
22
- // year: 2020,
23
- // month: 1,
24
- // day: dayOfWeekToIdx(dayOfWeek),
25
- // hour: hour,
26
- // minute: minute,
27
- // });
28
- // }
29
-
30
- // export type DateTimeTime = Pick<DateTime, "hour" | "minute">;
31
- // export type DateTimeDate = Pick<DateTime, "year" | "month" | "day">;
32
-
33
- // export function dateTimeToTimeComponents(dateTime: DateTime): DateTimeTime {
34
- // return {
35
- // hour: dateTime.hour,
36
- // minute: dateTime.minute,
37
- // };
38
- // }
39
-
40
- // export function dateTimeToDateComponents(dateTime: DateTime): DateTimeDate {
41
- // return {
42
- // year: dateTime.year,
43
- // month: dateTime.month,
44
- // day: dateTime.day,
45
- // };
46
- // }
47
-
48
- // export function objectHasDate(obj: object) {
49
- // return "year" in obj;
50
- // }
51
-
52
- // export function objectHasTime(obj: object) {
53
- // return "hour" in obj;
54
- // }
55
-
56
- // export function dateTimeSetTime(
57
- // dateTime: DateTime,
58
- // time: DateTimeTime | DateTime = { hour: 0, minute: 0 }
59
- // ): DateTime {
60
- // const timeComp = objectHasTime(time)
61
- // ? dateTimeToTimeComponents(time as DateTime)
62
- // : time;
63
- // return dateTime.set(timeComp);
64
- // }
65
-
66
- // export function dateTimeSetDate(
67
- // dateTime: DateTime,
68
- // date: DateTimeDate | DateTime = { year: 2020, month: 1, day: 1 }
69
- // ): DateTime {
70
- // const dateComp = objectHasDate(date)
71
- // ? dateTimeToTimeComponents(date as DateTime)
72
- // : date;
73
- // return dateTime.set(dateComp);
74
- // }
75
-
76
- // export function dateTimeLocalFromUTCDate(date: Date) {
77
- // return DateTime.fromJSDate(date).toLocal();
78
- // }
79
-
80
- // export function dateTimeLocalToUTCDate(dateTime: DateTime) {
81
- // return dateTime.toUTC().toJSDate();
82
- // }
83
-
84
- // export function dateTimeFormatTime(dateTime: DateTime) {
85
- // return dateTime.toFormat("HH:MM");
86
- // }