@flamingo-stack/openframe-frontend-core 0.0.642 → 0.0.643-snapshot.20260916153353
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/chat-protocol/index.cjs +6 -3
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +6 -3
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/source-metadata.d.ts +16 -1
- package/dist/chat-protocol/source-metadata.d.ts.map +1 -1
- package/dist/{chunk-YM6L3WM5.js → chunk-27RD5XTP.js} +3 -3
- package/dist/{chunk-POPL3W2S.js → chunk-3DGRXC74.js} +3 -3
- package/dist/{chunk-2Z5FPHOL.cjs → chunk-3UBT2OIX.cjs} +20 -20
- package/dist/{chunk-2Z5FPHOL.cjs.map → chunk-3UBT2OIX.cjs.map} +1 -1
- package/dist/{chunk-6GY6DFIH.js → chunk-4WVWRFGP.js} +6 -6
- package/dist/{chunk-OYI3K5R6.cjs → chunk-65EVGKFV.cjs} +8 -14
- package/dist/chunk-65EVGKFV.cjs.map +1 -0
- package/dist/{chunk-6NHLZORM.js → chunk-7Q5XXPCB.js} +6 -6
- package/dist/{chunk-2NRLRRMR.cjs → chunk-7R2DIGG4.cjs} +319 -293
- package/dist/chunk-7R2DIGG4.cjs.map +1 -0
- package/dist/{chunk-3LXJEXPH.js → chunk-B3Z3RJRW.js} +2 -2
- package/dist/{chunk-N5C5P2LM.cjs → chunk-B5IFXCRF.cjs} +22 -22
- package/dist/{chunk-N5C5P2LM.cjs.map → chunk-B5IFXCRF.cjs.map} +1 -1
- package/dist/{chunk-YRSRP4U3.cjs → chunk-C5Y5T6GC.cjs} +15 -15
- package/dist/{chunk-YRSRP4U3.cjs.map → chunk-C5Y5T6GC.cjs.map} +1 -1
- package/dist/{chunk-VHB3I6F3.cjs → chunk-CBXZSTAG.cjs} +419 -445
- package/dist/chunk-CBXZSTAG.cjs.map +1 -0
- package/dist/{chunk-VKPTN5MT.cjs → chunk-DCCY54LU.cjs} +6 -6
- package/dist/{chunk-VKPTN5MT.cjs.map → chunk-DCCY54LU.cjs.map} +1 -1
- package/dist/{chunk-WL3PNUNY.cjs → chunk-FAD5WURS.cjs} +81 -81
- package/dist/{chunk-WL3PNUNY.cjs.map → chunk-FAD5WURS.cjs.map} +1 -1
- package/dist/{chunk-3IPL6G7S.js → chunk-FOSIR4QF.js} +260 -234
- package/dist/chunk-FOSIR4QF.js.map +1 -0
- package/dist/{chunk-MJ424FEC.js → chunk-HOGOQA2X.js} +2 -2
- package/dist/{chunk-SDGMLXIP.js → chunk-HPWLIYRL.js} +12 -25
- package/dist/chunk-HPWLIYRL.js.map +1 -0
- package/dist/{chunk-3I6XHQUD.js → chunk-I57XLISO.js} +54 -80
- package/dist/chunk-I57XLISO.js.map +1 -0
- package/dist/{chunk-FRCUUK5X.cjs → chunk-IIXB5REN.cjs} +3 -3
- package/dist/{chunk-FRCUUK5X.cjs.map → chunk-IIXB5REN.cjs.map} +1 -1
- package/dist/{chunk-HW7BLVQH.js → chunk-IXD6SHQ6.js} +4 -4
- package/dist/{chunk-XFLJC2WR.cjs → chunk-LZYPSDFE.cjs} +59 -59
- package/dist/{chunk-XFLJC2WR.cjs.map → chunk-LZYPSDFE.cjs.map} +1 -1
- package/dist/{chunk-QY25ZP2V.cjs → chunk-MCQAOIUK.cjs} +28 -28
- package/dist/{chunk-QY25ZP2V.cjs.map → chunk-MCQAOIUK.cjs.map} +1 -1
- package/dist/{chunk-S254VEDE.js → chunk-MRIOYSXH.js} +3 -3
- package/dist/{chunk-OOOOC5O5.cjs → chunk-OMSUWB6A.cjs} +29 -29
- package/dist/{chunk-OOOOC5O5.cjs.map → chunk-OMSUWB6A.cjs.map} +1 -1
- package/dist/{chunk-GEIHTN6J.cjs → chunk-OVXYX47B.cjs} +10 -10
- package/dist/{chunk-GEIHTN6J.cjs.map → chunk-OVXYX47B.cjs.map} +1 -1
- package/dist/{chunk-XWGHLSAL.js → chunk-PFV4DAX5.js} +4 -4
- package/dist/{chunk-O4LL7RQV.cjs → chunk-RB6L5EGM.cjs} +208 -221
- package/dist/chunk-RB6L5EGM.cjs.map +1 -0
- package/dist/{chunk-M4PJVFBF.cjs → chunk-RFFF2EYD.cjs} +11 -11
- package/dist/{chunk-M4PJVFBF.cjs.map → chunk-RFFF2EYD.cjs.map} +1 -1
- package/dist/{chunk-UFBWNVZZ.js → chunk-RNMGKAS6.js} +7 -7
- package/dist/{chunk-SE6YRE3R.cjs → chunk-RWURXICE.cjs} +32 -32
- package/dist/{chunk-SE6YRE3R.cjs.map → chunk-RWURXICE.cjs.map} +1 -1
- package/dist/{chunk-ZAIYD3MZ.js → chunk-S2KMNFFN.js} +3 -3
- package/dist/{chunk-ZGPJ3NVF.js → chunk-SKABQX44.js} +3 -3
- package/dist/{chunk-YE3TFNW6.cjs → chunk-TGUA3C4U.cjs} +5 -5
- package/dist/{chunk-YE3TFNW6.cjs.map → chunk-TGUA3C4U.cjs.map} +1 -1
- package/dist/{chunk-ORFJVMAL.js → chunk-TTVOBWAH.js} +5 -11
- package/dist/chunk-TTVOBWAH.js.map +1 -0
- package/dist/{chunk-M7QROULE.js → chunk-UEXIMEVU.js} +5 -5
- package/dist/{chunk-EW3MSJOE.cjs → chunk-UKV52KAP.cjs} +33 -33
- package/dist/{chunk-EW3MSJOE.cjs.map → chunk-UKV52KAP.cjs.map} +1 -1
- package/dist/{chunk-J4RZVLLQ.js → chunk-VE52MSYC.js} +5 -5
- package/dist/components/case-studies/index.cjs +16 -16
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/chat-sidebar.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/blog-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +3 -9
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +2 -8
- package/dist/components/chat/types/entities/investor-update.d.ts.map +1 -1
- package/dist/components/chat/types/entities/program-types.d.ts +8 -18
- package/dist/components/chat/types/entities/program-types.d.ts.map +1 -1
- package/dist/components/chat/utils/compact-card-classes.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/docs/index.js +7 -7
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +5 -5
- package/dist/components/faq/index.js +4 -4
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +24 -24
- package/dist/components/help-center-pages/index.js +15 -15
- package/dist/components/index.cjs +53 -59
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +15 -21
- package/dist/components/index.js.map +1 -1
- package/dist/components/logs-list.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/confirmation.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/directory.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +47 -72
- package/dist/components/meeting-scheduler/index.cjs.map +1 -1
- package/dist/components/meeting-scheduler/index.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.js +16 -41
- package/dist/components/meeting-scheduler/index.js.map +1 -1
- package/dist/components/meeting-scheduler/slot-picker.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/navigation/index.js +6 -6
- package/dist/components/onboarding-guides/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.js +6 -6
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/shared/article-author-byline.d.ts.map +1 -1
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/date-picker.d.ts.map +1 -1
- package/dist/components/ui/device-card.d.ts.map +1 -1
- package/dist/components/ui/drawer.d.ts +19 -5
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +4 -10
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +3 -9
- package/dist/components/ui/table/table-timestamp-cell.d.ts.map +1 -1
- package/dist/index.cjs +29 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -23
- package/dist/index.js.map +1 -1
- package/dist/utils/date-formatters.d.ts +7 -2
- package/dist/utils/date-formatters.d.ts.map +1 -1
- package/dist/utils/date-utils.d.ts +4 -1
- package/dist/utils/date-utils.d.ts.map +1 -1
- package/dist/utils/format-date.d.ts.map +1 -1
- package/dist/utils/format.d.ts +155 -11
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/index.cjs +223 -109
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +211 -110
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/program-instant.d.ts +145 -0
- package/dist/utils/program-instant.d.ts.map +1 -0
- package/dist/utils/program-meta-renderers.d.ts +3 -0
- package/dist/utils/program-meta-renderers.d.ts.map +1 -0
- package/dist/utils/url-safety.d.ts +33 -0
- package/dist/utils/url-safety.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/source-metadata.test.ts +70 -3
- package/src/chat-protocol/source-metadata.ts +22 -6
- package/src/components/chat/chat-sidebar.tsx +4 -11
- package/src/components/chat/entity-cards/.program-card.md +1 -1
- package/src/components/chat/entity-cards/blog-card.tsx +4 -24
- package/src/components/chat/entity-cards/dispatch.tsx +9 -27
- package/src/components/chat/entity-cards/program-card.tsx +42 -81
- package/src/components/chat/types/entities/investor-update.ts +4 -6
- package/src/components/chat/types/entities/program-types.ts +8 -89
- package/src/components/chat/utils/.compact-card-classes.md +1 -1
- package/src/components/chat/utils/compact-card-classes.ts +5 -3
- package/src/components/logs-list.tsx +4 -13
- package/src/components/meeting-scheduler/confirmation.tsx +6 -10
- package/src/components/meeting-scheduler/directory.tsx +2 -12
- package/src/components/meeting-scheduler/index.tsx +3 -11
- package/src/components/meeting-scheduler/slot-picker.tsx +4 -7
- package/src/components/shared/article-author-byline.tsx +4 -13
- package/src/components/ui/.drawer.md +1 -0
- package/src/components/ui/__tests__/drawer-size.test.tsx +38 -0
- package/src/components/ui/date-picker.tsx +6 -13
- package/src/components/ui/device-card.tsx +4 -10
- package/src/components/ui/drawer.tsx +44 -9
- package/src/components/ui/table/table-timestamp-cell.tsx +8 -2
- package/src/utils/.format.md +5 -2
- package/src/utils/__tests__/date-rendering.test.ts +118 -0
- package/src/utils/__tests__/format-program-dates.test.ts +148 -0
- package/src/utils/__tests__/program-instant.test.ts +125 -0
- package/src/utils/__tests__/url-safety.test.ts +44 -0
- package/src/utils/date-formatters.ts +18 -29
- package/src/utils/date-utils.ts +27 -40
- package/src/utils/format-date.ts +14 -16
- package/src/utils/format.ts +367 -66
- package/src/utils/index.ts +24 -0
- package/src/utils/program-instant.ts +180 -0
- package/src/utils/program-meta-renderers.ts +18 -0
- package/src/utils/url-safety.ts +43 -0
- package/dist/chunk-2NRLRRMR.cjs.map +0 -1
- package/dist/chunk-3I6XHQUD.js.map +0 -1
- package/dist/chunk-3IPL6G7S.js.map +0 -1
- package/dist/chunk-O4LL7RQV.cjs.map +0 -1
- package/dist/chunk-ORFJVMAL.js.map +0 -1
- package/dist/chunk-OYI3K5R6.cjs.map +0 -1
- package/dist/chunk-SDGMLXIP.js.map +0 -1
- package/dist/chunk-VHB3I6F3.cjs.map +0 -1
- /package/dist/{chunk-YM6L3WM5.js.map → chunk-27RD5XTP.js.map} +0 -0
- /package/dist/{chunk-POPL3W2S.js.map → chunk-3DGRXC74.js.map} +0 -0
- /package/dist/{chunk-6GY6DFIH.js.map → chunk-4WVWRFGP.js.map} +0 -0
- /package/dist/{chunk-6NHLZORM.js.map → chunk-7Q5XXPCB.js.map} +0 -0
- /package/dist/{chunk-3LXJEXPH.js.map → chunk-B3Z3RJRW.js.map} +0 -0
- /package/dist/{chunk-MJ424FEC.js.map → chunk-HOGOQA2X.js.map} +0 -0
- /package/dist/{chunk-HW7BLVQH.js.map → chunk-IXD6SHQ6.js.map} +0 -0
- /package/dist/{chunk-S254VEDE.js.map → chunk-MRIOYSXH.js.map} +0 -0
- /package/dist/{chunk-XWGHLSAL.js.map → chunk-PFV4DAX5.js.map} +0 -0
- /package/dist/{chunk-UFBWNVZZ.js.map → chunk-RNMGKAS6.js.map} +0 -0
- /package/dist/{chunk-ZAIYD3MZ.js.map → chunk-S2KMNFFN.js.map} +0 -0
- /package/dist/{chunk-ZGPJ3NVF.js.map → chunk-SKABQX44.js.map} +0 -0
- /package/dist/{chunk-M7QROULE.js.map → chunk-UEXIMEVU.js.map} +0 -0
- /package/dist/{chunk-J4RZVLLQ.js.map → chunk-VE52MSYC.js.map} +0 -0
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Calendar-date presets.
|
|
3
|
+
*
|
|
4
|
+
* These format the DAY AS WRITTEN — the `YYYY-MM-DD` head of the input — so a
|
|
5
|
+
* `"2025-11-11"` never renders as Nov 10 west of UTC. The rendering itself is
|
|
6
|
+
* `formatDateWithTimezone` in `./format`: the day head is a UTC midnight
|
|
7
|
+
* rendered UTC-pinned, which is exactly the day written, on any machine. They
|
|
8
|
+
* used to look month names up in their own arrays.
|
|
4
9
|
*/
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
'January',
|
|
8
|
-
'February',
|
|
9
|
-
'March',
|
|
10
|
-
'April',
|
|
11
|
-
'May',
|
|
12
|
-
'June',
|
|
13
|
-
'July',
|
|
14
|
-
'August',
|
|
15
|
-
'September',
|
|
16
|
-
'October',
|
|
17
|
-
'November',
|
|
18
|
-
'December',
|
|
19
|
-
] as const;
|
|
11
|
+
import { type ZonedDateStyle, formatDateWithTimezone } from './format';
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
/** Render the calendar day an ISO date/date-time string names, or return the
|
|
14
|
+
* input unchanged if it has no `YYYY-MM-DD` head. */
|
|
15
|
+
function formatDayHead(dateString: string, style: ZonedDateStyle): string {
|
|
16
|
+
const ymd = splitYmd(dateString);
|
|
17
|
+
if (!ymd) return dateString;
|
|
18
|
+
return formatDateWithTimezone(ymd.join('-'), null, style) || dateString;
|
|
19
|
+
}
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
22
|
* Split an ISO date / date-time string into `[year, month, day]` strings.
|
|
@@ -37,10 +35,7 @@ function splitYmd(dateString: string): [string, string, string] | null {
|
|
|
37
35
|
* @returns e.g. `"November 11, 2025"`
|
|
38
36
|
*/
|
|
39
37
|
export function formatReleaseDate(dateString: string): string {
|
|
40
|
-
|
|
41
|
-
if (!ymd) return dateString;
|
|
42
|
-
const [year, month, day] = ymd;
|
|
43
|
-
return `${MONTHS_LONG[parseInt(month) - 1]} ${parseInt(day)}, ${year}`;
|
|
38
|
+
return formatDayHead(dateString, 'long');
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
/**
|
|
@@ -51,10 +46,7 @@ export function formatReleaseDate(dateString: string): string {
|
|
|
51
46
|
* lib chat cards (campaign-card-admin).
|
|
52
47
|
*/
|
|
53
48
|
export function formatDateShort(dateString: string): string {
|
|
54
|
-
|
|
55
|
-
if (!ymd) return dateString;
|
|
56
|
-
const [year, month, day] = ymd;
|
|
57
|
-
return `${MONTHS_SHORT[parseInt(month) - 1]} ${parseInt(day)}, ${year}`;
|
|
49
|
+
return formatDayHead(dateString, 'medium');
|
|
58
50
|
}
|
|
59
51
|
|
|
60
52
|
/**
|
|
@@ -63,8 +55,5 @@ export function formatDateShort(dateString: string): string {
|
|
|
63
55
|
* interview cards where the compact MM/DD/YYYY layout is desired.
|
|
64
56
|
*/
|
|
65
57
|
export function formatDateSlashUTC(dateString: string): string {
|
|
66
|
-
|
|
67
|
-
if (!ymd) return dateString;
|
|
68
|
-
const [year, month, day] = ymd;
|
|
69
|
-
return `${month}/${day}/${year}`;
|
|
58
|
+
return formatDayHead(dateString, 'numeric');
|
|
70
59
|
}
|
package/src/utils/date-utils.ts
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified Date Utilities for OpenMSP Platform
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Relative-time logic lives here; every ABSOLUTE date or time these helpers
|
|
5
|
+
* print is rendered by `formatDateWithTimezone` in `./format`, with the zone
|
|
6
|
+
* stated explicitly — never by a local `toLocale*` call or hand-built string.
|
|
4
7
|
*/
|
|
5
8
|
|
|
9
|
+
import { formatDateWithTimezone } from './format';
|
|
10
|
+
|
|
11
|
+
/** `mediumDateTime`'s fields, spread so a caller's own options still override. */
|
|
12
|
+
const ZONED_DATE_FIELDS_MEDIUM_DATETIME: Intl.DateTimeFormatOptions = {
|
|
13
|
+
year: 'numeric',
|
|
14
|
+
month: 'short',
|
|
15
|
+
day: 'numeric',
|
|
16
|
+
hour: 'numeric',
|
|
17
|
+
minute: '2-digit',
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
/**
|
|
7
21
|
* Relative display label for a ticket timestamp (ISO string).
|
|
8
22
|
* < 1 min → "Just now" | 1-59 min → "X min ago" | 1-23 h → "X hour(s) ago" | 24+ h → "MM/DD/YYYY"
|
|
@@ -17,30 +31,17 @@ export function formatTicketRelativeTime(iso: string): string {
|
|
|
17
31
|
if (diffMin < 60) return `${diffMin} min ago`;
|
|
18
32
|
const diffHours = Math.floor(diffMin / 60);
|
|
19
33
|
if (diffHours < 24) return diffHours === 1 ? '1 hour ago' : `${diffHours} hours ago`;
|
|
20
|
-
// UTC
|
|
21
|
-
|
|
22
|
-
const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
23
|
-
const dd = String(date.getUTCDate()).padStart(2, '0');
|
|
24
|
-
const yyyy = date.getUTCFullYear();
|
|
25
|
-
return `${mm}/${dd}/${yyyy}`;
|
|
34
|
+
// UTC-pinned through the one renderer — see `formatDateWithTimezone`.
|
|
35
|
+
return formatDateWithTimezone(date, null, 'numeric');
|
|
26
36
|
}
|
|
27
37
|
|
|
28
38
|
/**
|
|
29
39
|
* Full tooltip timestamp in "MM/DD/YYYY, H:MM AM/PM" format.
|
|
30
40
|
*/
|
|
31
41
|
export function formatTicketFullTimestamp(iso: string): string {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// client (local) — otherwise React #418 hydration mismatch.
|
|
36
|
-
const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
37
|
-
const dd = String(date.getUTCDate()).padStart(2, '0');
|
|
38
|
-
const yyyy = date.getUTCFullYear();
|
|
39
|
-
let hours = date.getUTCHours();
|
|
40
|
-
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
|
41
|
-
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
42
|
-
hours = hours % 12 || 12;
|
|
43
|
-
return `${mm}/${dd}/${yyyy}, ${hours}:${minutes} ${ampm}`;
|
|
42
|
+
// UTC-pinned through the one renderer — see `formatDateWithTimezone`. This was
|
|
43
|
+
// a hand-assembled `MM/DD/YYYY, H:MM AM` built from `getUTC*` getters.
|
|
44
|
+
return formatDateWithTimezone(iso, null, 'numericDateTime');
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -95,11 +96,10 @@ export function formatRelativeTime(timestamp: string | Date): string {
|
|
|
95
96
|
// Older than 30 days - show formatted date, pinned to UTC so SSR (UTC) and
|
|
96
97
|
// the client agree (React #418). Year comparison also uses UTC for the same
|
|
97
98
|
// reason (avoids a server/client split right at a year boundary).
|
|
98
|
-
return targetTime
|
|
99
|
+
return formatDateWithTimezone(targetTime, null, {
|
|
99
100
|
month: 'short',
|
|
100
101
|
day: 'numeric',
|
|
101
102
|
year: targetTime.getUTCFullYear() !== now.getUTCFullYear() ? 'numeric' : undefined,
|
|
102
|
-
timeZone: 'UTC',
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -118,17 +118,13 @@ export function formatAbsoluteDate(timestamp: string | Date, options: Intl.DateT
|
|
|
118
118
|
return 'Invalid date';
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
// UTC unless the caller names a zone; `options.timeZone` is passed as THE zone.
|
|
122
|
+
return formatDateWithTimezone(targetTime, options.timeZone ?? null, {
|
|
122
123
|
year: 'numeric',
|
|
123
124
|
month: 'short',
|
|
124
125
|
day: 'numeric',
|
|
125
|
-
// Pin to UTC so SSR (Vercel = UTC) and the client agree (React #418).
|
|
126
|
-
// Caller can override via `options`.
|
|
127
|
-
timeZone: 'UTC',
|
|
128
126
|
...options,
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
return targetTime.toLocaleDateString('en-US', defaultOptions);
|
|
127
|
+
});
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
/**
|
|
@@ -146,19 +142,10 @@ export function formatDateTime(timestamp: string | Date, options: Intl.DateTimeF
|
|
|
146
142
|
return 'Invalid date';
|
|
147
143
|
}
|
|
148
144
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
month: 'short',
|
|
152
|
-
day: 'numeric',
|
|
153
|
-
hour: 'numeric',
|
|
154
|
-
minute: '2-digit',
|
|
155
|
-
// Pin to UTC so SSR (Vercel = UTC) and the client agree (React #418).
|
|
156
|
-
// Caller can override via `options`.
|
|
157
|
-
timeZone: 'UTC',
|
|
145
|
+
return formatDateWithTimezone(targetTime, options.timeZone ?? null, {
|
|
146
|
+
...ZONED_DATE_FIELDS_MEDIUM_DATETIME,
|
|
158
147
|
...options,
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
return targetTime.toLocaleDateString('en-US', defaultOptions);
|
|
148
|
+
});
|
|
162
149
|
}
|
|
163
150
|
|
|
164
151
|
/**
|
package/src/utils/format-date.ts
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
// Locale-aware date/time formatters — mirrors openframe-frontend
|
|
2
|
-
// `src/lib/format-date.ts`. Formats follow the user's
|
|
3
|
-
// (e.g. MM/DD/YYYY in en-US vs DD.MM.YYYY in european locales)
|
|
2
|
+
// `src/lib/format-date.ts`. Formats follow the user's LOCALE and ZONE
|
|
3
|
+
// (e.g. MM/DD/YYYY in en-US vs DD.MM.YYYY in european locales): these back the
|
|
4
|
+
// dashboard's client-rendered tables, where "your local time" is the meaning.
|
|
5
|
+
//
|
|
6
|
+
// Rendered by `formatDateWithTimezone` in `./format` with the viewer zone and
|
|
7
|
+
// locale stated explicitly — not by a second set of `Intl` instances here.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
import { formatDateWithTimezone, VIEWER_TIMEZONE } from './format';
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
type DateInput = string | number | Date;
|
|
8
12
|
|
|
9
|
-
// Shown when the input is missing or unparseable
|
|
10
|
-
//
|
|
11
|
-
// here guards first — callers can pass raw API values without a per-call check.
|
|
13
|
+
// Shown when the input is missing or unparseable, so callers can pass raw API
|
|
14
|
+
// values without a per-call check.
|
|
12
15
|
const INVALID_DATE_PLACEHOLDER = '—';
|
|
13
16
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const format = (input: DateInput, fmt: Intl.DateTimeFormat): string => {
|
|
18
|
-
const date = toDate(input);
|
|
19
|
-
return Number.isNaN(date.getTime()) ? INVALID_DATE_PLACEHOLDER : fmt.format(date);
|
|
20
|
-
};
|
|
17
|
+
const render = (input: DateInput, fields: Intl.DateTimeFormatOptions): string =>
|
|
18
|
+
formatDateWithTimezone(input, VIEWER_TIMEZONE, fields, { viewerLocale: true }) || INVALID_DATE_PLACEHOLDER;
|
|
21
19
|
|
|
22
|
-
export const formatDate = (input: DateInput): string =>
|
|
20
|
+
export const formatDate = (input: DateInput): string => render(input, { dateStyle: 'short' });
|
|
23
21
|
|
|
24
|
-
export const formatTime = (input: DateInput): string =>
|
|
22
|
+
export const formatTime = (input: DateInput): string => render(input, { timeStyle: 'short' });
|