Skip to content

Commit ebd78b2

Browse files
committed
fix: format ISO datetimes with Z or offset suffix in roxy-data
1 parent e29371b commit ebd78b2

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

packages/ui/src/components/data.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const TITLE_KEYS = ['title', 'name', 'label', 'heading', 'overview', 'summary'];
3434
const IMAGE_KEYS = ['imageUrl', 'image', 'icon', 'symbol'];
3535
const SKIP_KEYS = ['imageUrl', 'image']; // rendered separately, not in body rows
3636

37-
const ISO_DATE = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2})?)?$/;
37+
const ISO_DATE =
38+
/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
3839
const ENUM_STRING = /^[A-Z0-9]+(_[A-Z0-9]+)+$/;
3940
const LINK_STRING = /^https?:\/\//;
4041

packages/ui/tests/components.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,14 @@ describe('roxy-data scalar formatting and structure', () => {
10171017
el.remove();
10181018
});
10191019

1020+
test('formats UTC-suffixed ISO datetimes', async () => {
1021+
const el = await mount({ datetime: '2026-07-10T01:09:25Z' });
1022+
const text = el.shadowRoot?.textContent ?? '';
1023+
expect(text).toContain('Jul');
1024+
expect(text).not.toContain('2026-07-10T01:09:25Z');
1025+
el.remove();
1026+
});
1027+
10201028
test('promotes object values to full-width sections, not dl cells', async () => {
10211029
const el = await mount({
10221030
score: 87,

0 commit comments

Comments
 (0)