metonym / svelte-time

Svelte component and action to format a timestamp using day.js
https://metonym.github.io/svelte-time
MIT License
137 stars 8 forks source link

Switching format after an amount of time #11

Open omar2205 opened 2 years ago

omar2205 commented 2 years ago

I want to use the relative time, 'a minute ago', but after a couple of hours, I want to switch it to say `04:40 am'.

metonym commented 2 years ago

This would also be useful for customizing a formatted date to also include the relative timestamp.

Jan. 2020 (2 years ago)

The API could look like:

<Time format="MM. YYYY" display={({ relative, formatted }) => `${formatted} (${relative})`} />