forked from Kieran/snort
Merge pull request #166 from wanacode/timehover
Show absolute time on hover
This commit is contained in:
commit
5b091d5d33
@ -12,6 +12,8 @@ export interface NoteTimeProps {
|
|||||||
export default function NoteTime(props: NoteTimeProps) {
|
export default function NoteTime(props: NoteTimeProps) {
|
||||||
const [time, setTime] = useState<string>();
|
const [time, setTime] = useState<string>();
|
||||||
const { from, fallback } = props;
|
const { from, fallback } = props;
|
||||||
|
const absoluteTime = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'long'}).format(from);
|
||||||
|
const isoDate = new Date(from).toISOString();
|
||||||
|
|
||||||
function calcTime() {
|
function calcTime() {
|
||||||
let fromDate = new Date(from);
|
let fromDate = new Date(from);
|
||||||
@ -46,5 +48,5 @@ export default function NoteTime(props: NoteTimeProps) {
|
|||||||
return () => clearInterval(t);
|
return () => clearInterval(t);
|
||||||
}, [from]);
|
}, [from]);
|
||||||
|
|
||||||
return <>{time}</>
|
return <time dateTime={isoDate} title={absoluteTime}>{time}</time>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user