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:
milliseconds
seconds
minutes
hours
Days-level:
Months-level:
months
quarters
years
decades
centuries
millennia
Upon object creation, normalize / balance to the largest given unit within each level.
Properties and methods:
iso
toString() => iso
toJson() => iso
valueOf() => number tally milliseconds
is(other: Duration) => boolean equality check
round() => Duration
rescale(shape: SloppyDuration) => Duration
add(duration: Duration): Duration
subtract(duration: Duration): Duration
asHours(), asDays(), etc
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!
Create factory function
Durationfor 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:
millisecondssecondsminuteshoursDays-level:
daysweeksMonths-level:
monthsquartersyearsdecadescenturiesmillenniaUpon object creation, normalize / balance to the largest given unit within each level.
Properties and methods:
isotoString() => isotoJson() => isovalueOf() => numbertally millisecondsis(other: Duration) => booleanequality checkround() => Durationrescale(shape: SloppyDuration) => Durationadd(duration: Duration): Durationsubtract(duration: Duration): DurationasHours(),asDays(), etcUse
Intlnumber 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!