Skip to content

Commit

Permalink
Fix tooltip for dates without time (mastodon#24244)
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 authored Apr 7, 2023
1 parent 9ef9974 commit aa136cf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/javascript/packs/public.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ function main() {
const datetime = new Date(content.getAttribute('datetime'));
const now = new Date();

content.title = dateTimeFormat.format(datetime);
const timeGiven = content.getAttribute('datetime').includes('T');
content.title = timeGiven ? dateTimeFormat.format(datetime) : dateFormat.format(datetime);
content.textContent = timeAgoString({
formatMessage: ({ id, defaultMessage }, values) => (new IntlMessageFormat(messages[id] || defaultMessage, locale)).format(values),
formatDate: (date, options) => (new Intl.DateTimeFormat(locale, options)).format(date),
}, datetime, now, now.getFullYear(), content.getAttribute('datetime').includes('T'));
}, datetime, now, now.getFullYear(), timeGiven);
});

const reactComponents = document.querySelectorAll('[data-component]');
Expand Down

0 comments on commit aa136cf

Please sign in to comment.