Displaying shorthand dates/time?
-
How would I go about using shorter hand time ago?
Currently:10 hours ago
Shorthand:10h
-
If it's just for one NodeBB instance you coud hard-code sth. like
$.timeago.settings.strings = { prefixAgo: null, prefixFromNow: null, suffixAgo: "", suffixFromNow: "", seconds: "1m", minute: "1m", minutes: "%dm", hour: "1h", hours: "%dh", day: "1d", days: "%dd", month: "1mo", months: "%dmo", year: "1yr", years: "%dyr", wordSeparator: " ", numbers: [] };
within public/src/app.js before
$('span.timeago').timeago();
If it's for a theme/plugin you could add the same into any client-side script that triggers on page-load (like entries within plugin.json attribute scripts).
I've taken the object from public/vendor/jquery/timeago/locales/jquery.timeago.en-short.js, there are several others that may inspire youI've taken the method from here, maybe there exists an easier way to change the locale now since this is a 3.5a old thread... but this issue lets me assume that it's not implemented yet ^^
-
@frissdiegurke Thanks, I'll give it a shot!
-
Yeah, the timeago library doesn't support shorthand dates, and only treats it like a separate language file, so it replaces it site-wide. Even then, the timeago string is shorthand English, so that leaves international users out in the cold too.
-
@julian said:
Yeah, the timeago library doesn't support shorthand dates, and only treats it like a separate language file, so it replaces it site-wide. Even then, the timeago string is shorthand English, so that leaves international users out in the cold too.
Hardcoded in
jquery.timeago.min.js
-
Yeah, like @frissdiegurke mentioned, timeago uses separate locale files to override the "templates", but there's no way to use multiple templates based on the situation (shorthand for some, full for others, etc) without fundamental changes to timeago itself.