online-judge
online-judge copied to clipboard
Increase precision on relative time offsets
Fixes #1846. Makes moment.js redundant. The new relative time messages will be:
-
1 second
to119 seconds
-
2 minutes
to179 minutes
-
3 hours
to47 hours
-
2 days
to99 days
This diff is friendly towards i18n. German example:
As a failsafe, always use absolute time if the browser doesn't support Math.trunc
and Intl.RelativeTimeFormat
. For example, IE11.
Codecov Report
Merging #1990 (4c7f6d0) into master (1bd9be0) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #1990 +/- ##
=======================================
Coverage 46.51% 46.51%
=======================================
Files 236 236
Lines 13085 13085
=======================================
Hits 6086 6086
Misses 6999 6999
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
Fun fact: Intl.RelativeTimeFormat
supports fractional amounts, e.g. rtf.format(-3.14159, 'minute')
becomes '3.142 minutes ago'
.
I only used integer amounts in this pr, because there's no need for fractional amounts right now.
2 minutes to 179 minutes
👀