-
Notifications
You must be signed in to change notification settings - Fork 179
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
Reimplement relative time formatting as a filter, dropping dependency on deprecated moment.js #1450
Conversation
LGTM |
Codecov Report
@@ Coverage Diff @@
## master #1450 +/- ##
============================================
+ Coverage 91.93% 91.94% +0.01%
Complexity 759 759
============================================
Files 64 64
Lines 2776 2769 -7
============================================
- Hits 2552 2546 -6
+ Misses 224 223 -1
Continue to review full report at Codecov.
|
Could you do a rebase? We merged a fix for the tests. |
… on deprecated moment.js Signed-off-by: Alec Kojaev <alec@kojaev.name>
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected.
I stumbled over the missing months though, even 12 weeks
(your 90 days threshold) is not a common unit for me, making this more confusing to me than an absolute date. It's probably personal preference, but find absolute dates better to understand than large relative ones.
Regarding the improved performance, I couldn't do any tests on my test instance.
I'm not sure if this will be a longer term solution or if this will change with the new vue based front end.
Thank you very much @oldnomad :) And I assume that with the vue rewrite this might be replaced, maybe until then Nextcloud also has a new lib that respects the Nextlcloud localization |
This PR offers a more complete solution than #1441, and replaces it.
This is a re-implementation of relative date/time formatting (
getRelativeDate()
), which was mentioned in #1433. Original version used NodeJS modulemoment.js
, which is obsolete, deprecated, and slated for removal from Nextcloud base.This version implements relative formatting as a filter, instead of a controller method. It uses pure JavaScript
Intl.RelativeTimeFormat
, with fallback to plain date formatting for older browsers. Dependency onmoment.js
is dropped. The new function is, however, slightly different from the original: