formkit / tempo

📆 Parse, format, manipulate, and internationalize dates and times in JavaScript and TypeScript.
https://tempo.formkit.com
MIT License
2.2k stars 26 forks source link

Feature Request: Relative Time #7

Open saturnonearth opened 4 months ago

saturnonearth commented 4 months ago

Would love to see a "format relative time" helper, like date-fns

See: https://github.com/date-fns/date-fns/blob/f4e22da16/src/formatRelative/index.ts#L54

mirague commented 4 months ago

I was looking for a "1 hour ago" relative time formatter as well in the (great) documentation and surprised it wasn't there. Adding this would make this even more powerful and complete.

justin-schroeder commented 4 months ago

I would love this too — although the native relative time format is already quite good:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat

Perhaps tempo could offer pure syntactic sugar around this call.

maninak commented 3 months ago

The versatility and ergonomics of javascript-time-ago, especially their Custom config, are worth looking into for inspiration.