bjuppa / com-plain-date

JavaScript date-time utilities that keep timezones on the surface
https://deno.land/x/complaindate/mod.ts
MIT License
1 stars 0 forks source link

Add an object type and utils for durations #75

Open bjuppa opened 1 year ago

bjuppa commented 1 year ago

Create factory function Duration for duration objects (time-period, span, stretch), like 3 days, 4 hours, 25 minutes.

Some resolution units to consider, each can be negative, at least one needs to be given:

Time-level:

Days-level:

Months-level:

Upon object creation, normalize / balance to the largest given unit within each level.

Properties and methods:

Use Intl number format to localise strings using units. See how Luxon does this! Check Temporal for balancing https://tc39.es/proposal-temporal/docs/balancing.html and compare that to Luxon's round, rescale & shift!

bjuppa commented 1 year ago

These are just my quick thoughts jotted down! ☝️

Please contribute your ideas about balancing/rescaling/normalizing!

bjuppa commented 6 months ago

For creating human readable strings of a duration, we should look into Intl RelativeTimeFormat

https://www.raymondcamden.com/2024/03/07/using-intlrelativetimeformat-for-localized-relative-timings