Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,42 @@ describe('FullDetailsTable', () => {
expect(screen.getByText('Restricted')).toBeInTheDocument();
});

it('preserves a year-only Date Issued value', () => {
const data = {
...baseData,
attributes: {
...baseData.attributes,
ogm: {
...baseData.attributes.ogm,
dct_issued_s: '1950',
},
},
};

renderWithRouter(<FullDetailsTable data={data} />);

expect(screen.getByText('Date Issued')).toBeInTheDocument();
expect(screen.getByText('1950')).toBeInTheDocument();
expect(screen.queryByText('January 1, 1950')).not.toBeInTheDocument();
});

it('formats a full Date Issued value with month and day', () => {
const data = {
...baseData,
attributes: {
...baseData.attributes,
ogm: {
...baseData.attributes.ogm,
dct_issued_s: '2019-01-15',
},
},
};

renderWithRouter(<FullDetailsTable data={data} />);

expect(screen.getByText('January 15, 2019')).toBeInTheDocument();
});

it('metadata facet labels use sequential heading level (h3 under h2)', () => {
const data = {
...baseData,
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/components/resource/FullDetailsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,14 @@ export function FullDetailsTable({ data }: FullDetailsTableProps) {
// IMPORTANT: make this deterministic across SSR/client.
// Manually parse YYYY-MM-DD to avoid `new Date(string)` ambiguity and timezone offsets.
// We strictly interpret the date string as UTC YYYY-MM-DD.
const valStr = value.toString();
const valStr = value.toString().trim();

// Date Issued often has year-level precision. Preserve that precision instead
// of allowing `new Date("2024")` to invent January 1 as a month and day.
if (key === 'dct_issued_s' && /^\d{4}$/.test(valStr)) {
return valStr;
}

// Match YYYY-MM-DD pattern (stripping time if present)
const match = valStr.match(/^(\d{4})-(\d{2})-(\d{2})/);

Expand Down
Loading