Skip to content

Commit d80ec43

Browse files
c960657skerit
authored andcommitted
Fix tooltip for dates without time (mastodon#24244)
1 parent c3e659c commit d80ec43

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/javascript/packs/public.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ function main() {
117117
const datetime = new Date(content.getAttribute('datetime'));
118118
const now = new Date();
119119

120-
content.title = dateTimeFormat.format(datetime);
120+
const timeGiven = content.getAttribute('datetime').includes('T');
121+
content.title = timeGiven ? dateTimeFormat.format(datetime) : dateFormat.format(datetime);
121122
content.textContent = timeAgoString({
122123
formatMessage: ({ id, defaultMessage }, values) => (new IntlMessageFormat(messages[id] || defaultMessage, locale)).format(values),
123124
formatDate: (date, options) => (new Intl.DateTimeFormat(locale, options)).format(date),
124-
}, datetime, now, now.getFullYear(), content.getAttribute('datetime').includes('T'));
125+
}, datetime, now, now.getFullYear(), timeGiven);
125126
});
126127

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

0 commit comments

Comments
 (0)