Commit f3accf4
Downloads (MacOS): show relative date
This is yet another thing that was computed server-side but can be
computed on the client side instead.
The logic for the approximate date difference was inspired by
https://github.com/rails/rails/blob/4136145819ab/actionview/lib/action_view/helpers/date_helper.rb#L29-L158
(because this was used indirectly in the Rails app, via the
`time_ago_in_words` function).
However, rather than reimplementing all of that complicated logic, let's
implement a vastly simpler yet still similar logic that imitates how
that Rails function handles year-long differencess: up to 25% longer a
time difference and we say "about X ago", up to 25% shorter and we say
"almost X ago", otherwise we say "over X ago".
Co-authored-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>1 parent 129b879 commit f3accf4
2 files changed
+31
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| |||
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
317 | | - | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
318 | 347 | | |
319 | 348 | | |
320 | 349 | | |
| |||
0 commit comments