3 ms·
I recently came across this conumdrum myself when developing a live streaming web app[1]. The app formats a DateTime using a fuzzy relative duration[2] which di
by hbcondo714 3y ago
I recently came across this conumdrum myself when developing a live streaming web app[1]. The app formats a DateTime using a fuzzy relative duration[2] which displays "1 minute ago", "2 days ago", "yesterday", etc...
I also concur with the author of the post saying "ago" is not enough. So the app has been updated to display:
fuzzy relative duration
hour:minute:second period timezone
full_day_name abbreviated_month_name day_number
I had to write a bit of logic[3] since new items only arrive on weekdays so when viewed on the weekend, new items do not say "23 hours ago" and instead say "yesterday".
[1] https://live.last10k.com https://live.last10k.com
[2] https://hexdocs.pm/timex/Timex.html#from_now/3 https://hexdocs.pm/timex/Timex.html#from_now/3
[3] https://github.com/hbcondo/last10k_liveview/blob/main/lib/last10k_web/live/filings_live.ex#L138C1-L149C20 https://github.com/hbcondo/last10k_liveview/blob/main/lib/la...