feat(home): improve world clock accessibility

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2023-05-15 22:53:04 +02:00
parent eecf5f100f
commit b6b7f1642c
2 changed files with 13 additions and 6 deletions
@@ -103,6 +103,6 @@ describe('HeaderWorldClock with custom Time Format', () => {
/>,
);
expect(rendered.getByText('09:10')).toBeInTheDocument();
expect(rendered.getByText('09:10')).toHaveAttribute('datetime', '09:10');
});
});
@@ -23,8 +23,9 @@ const timeFormat: Intl.DateTimeFormatOptions = {
};
type TimeObj = {
time: string;
label: string;
value: string;
dateTime: string;
};
/** @public */
@@ -65,8 +66,14 @@ function getTimes(
label = 'GMT';
}
const time = d.toLocaleTimeString(lang, options);
clocks.push({ time, label });
const value = d.toLocaleTimeString(lang, options);
const dateTime = d.toLocaleTimeString(lang, {
timeZone: options.timeZone,
hour: '2-digit',
minute: '2-digit',
hour12: false,
});
clocks.push({ label, value, dateTime });
}
return clocks;
@@ -129,9 +136,9 @@ export const HeaderWorldClock = (props: {
<>
{clocks.map(clock => (
<HeaderLabel
label={clock.label}
value={clock.time}
key={clock.label}
label={clock.label}
value={<time dateTime={clock.dateTime}>{clock.value}</time>}
/>
))}
</>