Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tooltip for dates without time #24244

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Format dates without time
  • Loading branch information
c960657 committed Mar 24, 2023
commit a489ff10c4206b4c56fb4d672d0980b895f84b91
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