I want to create a date range picker component for the charts I was building, but I want it to be able to display the range as human readable text when possible.
It should display text like:
today
yesterday
last n days
last n weeks
Jan 1st - Jan 5th
So I built a function that takes two dates, from
and to
, and formats them accordingly.
Code
https://svelte.dev/repl/5133e2afce94407f84bdde0d59e23301?version=3.38.3