@bash-app/bash-common 3.2.0 → 3.3.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": "3.2.0",
3
+ "version": "3.3.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",
@@ -14,7 +14,7 @@ export const DATETIME_FORMAT_STANDARD = "MMM D, YYYY - h:mm A";
14
14
  export const DATETIME_FORMAT_ISO_LIKE = "YYYY-MM-DD HH:mm"
15
15
  export const DATE_FORMAT_STANDARD = "MM/DD/YYYY";
16
16
  export const DATE_FORMAT_ISO = "YYYY-MM-DD";
17
- export const TIME_FORMAT_AM_PM = "hh:mm A";
17
+ export const TIME_FORMAT_AM_PM = "h:mm A";
18
18
 
19
19
  export interface ITime {
20
20
  hours: number;
@@ -22,6 +22,16 @@ export interface ITime {
22
22
  ampm: string;
23
23
  }
24
24
 
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)}`;
30
+ }
31
+
32
+ return `${startDateTime.format(DATETIME_FORMAT_STANDARD)} to ${endDateTime.format(DATETIME_FORMAT_STANDARD)}`;
33
+ }
34
+
25
35
  export function ensureIsDateTime(possiblyADate: DateTimeArgType): Date | undefined {
26
36
  if (!possiblyADate) {
27
37
  return undefined;