Add support for hovering over some dates to see the non-recent day

This commit is contained in:
Aurora Lahtela 2024-03-26 20:53:16 +02:00
parent fff2f329a7
commit 1bb9437ed2
2 changed files with 8 additions and 2 deletions

View File

@ -58,7 +58,7 @@ const Header = ({page, tab, hideUpdater}) => {
</button>}
{staticSite && <Fa icon={faClockRotateLeft} title={t('html.label.exported')}/>}
{' '}
<span className="refresh-time"><FormattedDate date={lastUpdate.date}/></span>
<span className="refresh-time"><FormattedDate date={lastUpdate.date} react/></span>
</div>
</>}

View File

@ -40,7 +40,7 @@ export function formatDate(date, offset, pattern, recentDays, recentDaysPattern,
return date !== 0 ? new SimpleDateFormat(format).format(timestamp) : '-'
}
const FormattedDate = ({date}) => {
const FormattedDate = ({date, react}) => {
const {t} = useTranslation();
const {pattern, recentDays, recentDaysPattern, offset} = useDatePreferences();
@ -48,6 +48,12 @@ const FormattedDate = ({date}) => {
if (!pattern || date === undefined || date === null) return <></>;
if (!isNumber(date)) return date;
if (react) {
return <span title={formatDate(date, offset, pattern, false, null, t)}>
{formatDate(date, offset, pattern, recentDays, recentDaysPattern, t)}
</span>
}
return formatDate(date, offset, pattern, recentDays, recentDaysPattern, t);
};