@bash-app/bash-common 30.474.0 → 30.477.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/dist/__tests__/audienceImport.test.js +3 -0
- package/dist/__tests__/audienceImport.test.js.map +1 -1
- package/dist/__tests__/eventTimezoneIana.test.js +23 -8
- package/dist/__tests__/eventTimezoneIana.test.js.map +1 -1
- package/dist/__tests__/promoCodeScope.test.js +7 -0
- package/dist/__tests__/promoCodeScope.test.js.map +1 -1
- package/dist/audienceImport.d.ts.map +1 -1
- package/dist/audienceImport.js +3 -1
- package/dist/audienceImport.js.map +1 -1
- package/dist/extendedSchemas.d.ts +1 -0
- package/dist/extendedSchemas.d.ts.map +1 -1
- package/dist/extendedSchemas.js +1 -0
- package/dist/extendedSchemas.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/promoCodeScope.d.ts +2 -0
- package/dist/promoCodeScope.d.ts.map +1 -1
- package/dist/promoCodeScope.js +8 -3
- package/dist/promoCodeScope.js.map +1 -1
- package/dist/utils/__tests__/eventTimezoneIana.test.js +4 -4
- package/dist/utils/__tests__/eventTimezoneIana.test.js.map +1 -1
- package/dist/utils/eventTimezoneIana.d.ts +9 -3
- package/dist/utils/eventTimezoneIana.d.ts.map +1 -1
- package/dist/utils/eventTimezoneIana.js +62 -7
- package/dist/utils/eventTimezoneIana.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/audienceImport.test.ts +3 -0
- package/src/__tests__/eventTimezoneIana.test.ts +24 -7
- package/src/__tests__/promoCodeScope.test.ts +10 -0
- package/src/audienceImport.ts +5 -1
- package/src/extendedSchemas.ts +1 -0
- package/src/index.ts +1 -0
- package/src/promoCodeScope.ts +10 -3
- package/src/utils/__tests__/eventTimezoneIana.test.ts +4 -4
- package/src/utils/eventTimezoneIana.ts +71 -7
|
@@ -232,6 +232,7 @@ export function getIanaTimezoneFromLocationStringHints(
|
|
|
232
232
|
locationLower.includes("massachusetts") ||
|
|
233
233
|
/\bma\b/.test(locationLower) ||
|
|
234
234
|
locationLower.includes("florida") ||
|
|
235
|
+
locationLower.includes("miami") ||
|
|
235
236
|
/\bfl\b/.test(locationLower) ||
|
|
236
237
|
locationLower.includes("georgia") ||
|
|
237
238
|
/\bga\b/.test(locationLower) ||
|
|
@@ -434,21 +435,26 @@ export const EVENT_TIMEZONE_PICKER_ZONES: readonly string[] = [
|
|
|
434
435
|
];
|
|
435
436
|
|
|
436
437
|
/**
|
|
437
|
-
* For public surfaces:
|
|
438
|
-
*
|
|
439
|
-
*
|
|
438
|
+
* For public surfaces: a bash with a place is shown in that place's time.
|
|
439
|
+
* A viewer in Utah looking at a Miami bash sees Eastern time, not Utah time.
|
|
440
|
+
* Stored timezone and the host profile zone are only used when the place
|
|
441
|
+
* does not resolve to a zone. Never uses the viewer's device timezone.
|
|
440
442
|
*/
|
|
441
443
|
export function resolveEventTimezoneIanaForDisplay(
|
|
442
444
|
args: ResolveEventTimezoneForDisplayArgs
|
|
443
445
|
): string {
|
|
446
|
+
if (eventHasLocationHint(args)) {
|
|
447
|
+
const fromPlace = inferEventTimezoneIana(args);
|
|
448
|
+
if (fromPlace !== "UTC") return fromPlace;
|
|
449
|
+
}
|
|
450
|
+
|
|
444
451
|
const stored = args.timezone?.trim();
|
|
445
452
|
if (stored && isValidIanaTimezone(stored)) return stored;
|
|
446
453
|
|
|
447
454
|
const host = args.hostTimeZone?.trim();
|
|
448
|
-
if (host && isValidIanaTimezone(host))
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if (inferred !== "UTC") return inferred;
|
|
455
|
+
if (host && isValidIanaTimezone(host) && !eventHasLocationHint(args)) {
|
|
456
|
+
return host;
|
|
457
|
+
}
|
|
452
458
|
|
|
453
459
|
return "UTC";
|
|
454
460
|
}
|
|
@@ -477,3 +483,61 @@ export function formatBashEventWhenLabel(
|
|
|
477
483
|
const abbrev = formatEventTimezoneAbbrev(zone, parsed);
|
|
478
484
|
return abbrev ? `${time} ${abbrev}` : time;
|
|
479
485
|
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Start and end in the bash's place, with one zone label.
|
|
489
|
+
* Same-day ends show the clock only.
|
|
490
|
+
*/
|
|
491
|
+
export function formatBashEventWhenRange(
|
|
492
|
+
startDateTime: string | Date | null | undefined,
|
|
493
|
+
endDateTime: string | Date | null | undefined,
|
|
494
|
+
args: ResolveEventTimezoneForDisplayArgs
|
|
495
|
+
): string {
|
|
496
|
+
if (startDateTime == null) return "Date TBD";
|
|
497
|
+
const start =
|
|
498
|
+
startDateTime instanceof Date ? startDateTime : new Date(startDateTime);
|
|
499
|
+
if (Number.isNaN(start.getTime())) return "Date TBD";
|
|
500
|
+
|
|
501
|
+
const zone = resolveEventTimezoneIanaForDisplay(args);
|
|
502
|
+
const startText = new Intl.DateTimeFormat("en-US", {
|
|
503
|
+
timeZone: zone,
|
|
504
|
+
weekday: "short",
|
|
505
|
+
month: "short",
|
|
506
|
+
day: "numeric",
|
|
507
|
+
hour: "numeric",
|
|
508
|
+
minute: "2-digit",
|
|
509
|
+
}).format(start);
|
|
510
|
+
const abbrev = formatEventTimezoneAbbrev(zone, start);
|
|
511
|
+
|
|
512
|
+
const end =
|
|
513
|
+
endDateTime == null
|
|
514
|
+
? null
|
|
515
|
+
: endDateTime instanceof Date
|
|
516
|
+
? endDateTime
|
|
517
|
+
: new Date(endDateTime);
|
|
518
|
+
if (!end || Number.isNaN(end.getTime())) {
|
|
519
|
+
return abbrev ? `${startText} ${abbrev}` : startText;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
const dayKey = new Intl.DateTimeFormat("en-US", {
|
|
523
|
+
timeZone: zone,
|
|
524
|
+
year: "numeric",
|
|
525
|
+
month: "2-digit",
|
|
526
|
+
day: "2-digit",
|
|
527
|
+
});
|
|
528
|
+
const sameDay = dayKey.format(start) === dayKey.format(end);
|
|
529
|
+
const endText = new Intl.DateTimeFormat("en-US", {
|
|
530
|
+
timeZone: zone,
|
|
531
|
+
...(sameDay
|
|
532
|
+
? { hour: "numeric" as const, minute: "2-digit" as const }
|
|
533
|
+
: {
|
|
534
|
+
weekday: "short" as const,
|
|
535
|
+
month: "short" as const,
|
|
536
|
+
day: "numeric" as const,
|
|
537
|
+
hour: "numeric" as const,
|
|
538
|
+
minute: "2-digit" as const,
|
|
539
|
+
}),
|
|
540
|
+
}).format(end);
|
|
541
|
+
const body = `${startText} to ${endText}`;
|
|
542
|
+
return abbrev ? `${body} ${abbrev}` : body;
|
|
543
|
+
}
|