Merge pull request #166 from wanacode/timehover

Show absolute time on hover
This commit is contained in:
Kieran 2023-01-29 21:51:34 +00:00 committed by GitHub
commit 5b091d5d33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,8 @@ export interface NoteTimeProps {
export default function NoteTime(props: NoteTimeProps) {
const [time, setTime] = useState<string>();
const { from, fallback } = props;
const absoluteTime = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'long'}).format(from);
const isoDate = new Date(from).toISOString();
function calcTime() {
let fromDate = new Date(from);
@ -46,5 +48,5 @@ export default function NoteTime(props: NoteTimeProps) {
return () => clearInterval(t);
}, [from]);
return <>{time}</>
return <time dateTime={isoDate} title={absoluteTime}>{time}</time>
}