feat: friendly relative dates ("10 minutes ago")#480
Merged
Conversation
Render xsd:dateTime-style values as relative time in the viewer's local
timezone, with the full absolute date-time on hover, instead of raw ISO
strings like "2026-04-16T08:27:12.954Z".
- Utils.friendlyDateHtml / isDateTimeLiteral: emit a <time datetime="...">
element; ISO value is machine-readable, server text is the no-script fallback.
- QueryResultTable: ISO-looking result cells render as friendly dates.
- NanopubItem: footer creation time uses the same treatment, keeping the
existing server-formatted date as fallback.
- nanodash.js: renderFriendlyDates() rewrites <time.friendly-date> via
Intl.RelativeTimeFormat ("just now" / minutes / hours / days, then absolute
date beyond a week); full date-time in the title tooltip. Runs on load,
on Wicket AJAX complete, and in updateElements().
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dates that previously showed as raw ISO strings like
2026-04-16T08:27:12.954Znow render as friendly relative times ("10 minutes ago") in the viewer's local timezone, with the full pretty-printed date-time available on hover.just now/10 minutes ago/3 hours ago/yesterday(via the browser-nativeIntl.RelativeTimeFormat).16 Apr 2026).Thursday, 16 April 2026 at 10:27:12 GMT+2.Applied to two places:
How it works
Utils.friendlyDateHtml(iso, fallback)emits a<time class="friendly-date" datetime="…">element. Thedatetimeattribute is machine-readable; the element body is server-rendered text that stays visible if JS doesn't run.nanodash.jsrenderFriendlyDates()rewrites those elements client-side (so it gets the user's locale + timezone for free), running on load, on Wicket AJAX complete, and inupdateElements(). It's idempotent.Utils.isDateTimeLiteral()gates which query cells get the treatment.Caveats
2026-04-16) are left as-is, and a stray string matching the pattern would be treated as a date. A cleaner long-term fix is to have grlc mark temporal columns explicitly.Intl.RelativeTimeFormatsupport → shows the absolute date.Test plan
🤖 Generated with Claude Code