Duration57
Constructors
daysconstCreates a Duration from days.fromInputconstDecodes a Input value into a Duration safely, returning Option.none() if decoding fails.fromInputUnsafeconstDecodes a Duration.Input into a Duration.hoursconstCreates a Duration from hours.infinityconstA Duration representing infinite time.microsconstCreates a Duration from microseconds.millisconstCreates a Duration from milliseconds.minutesconstCreates a Duration from minutes.nanosconstCreates a Duration from nanoseconds.negativeInfinityconstA Duration representing negative infinite time.secondsconstCreates a Duration from seconds.weeksconstCreates a Duration from weeks.zeroconstA Duration representing zero time.Models
DurationinterfaceRepresents a span of time with high precision, supporting operations from nanoseconds to weeks.DurationObjectinterfaceAn object with optional duration components that can be combined to create a Duration.DurationValuetypeTagged representation of a Duration value.InputtypeValid input types that can be converted to a Duration.UnittypeValid time units that can be used in duration string representations.Guards
isDurationconstChecks whether a value is a Duration.isFiniteconstChecks whether a Duration is finite (not infinite).isNegativeconstReturns true if the duration is negative (strictly less than zero).isPositiveconstReturns true if the duration is positive (strictly greater than zero).isZeroconstChecks whether a Duration is zero.Getters
toDaysconstConverts a Duration to days.toHoursconstConverts a Duration to hours.toHrTimeconstConverts a Duration to high-resolution time format [seconds, nanoseconds].toMillisconstConverts a Duration to milliseconds.toMinutesconstConverts a Duration to minutes.toNanosconstGets the duration in nanoseconds safely as an Option<bigint>.toNanosUnsafeconstGets the duration in nanoseconds as a bigint.toSecondsconstConverts a Duration to seconds.toWeeksconstConverts a Duration to weeks.Converting
Instances
Math
absconstReturns the absolute value of the duration.CombinerMaxconstCombiner that returns the maximum Duration.CombinerMinconstCombiner that returns the minimum Duration.divideconstDivides a Duration by a finite, non-zero number safely.divideUnsafeconstDivides a Duration by a number using fallback rules instead of returning an Option.negateconstReturns the negated duration.ReducerSumconstReducer for summing Durations.subtractconstSubtracts one Duration from another.sumconstAdds two Durations together.timesconstReturns a Duration multiplied by a number.Ordering
Pattern Matching
Predicates
betweenconstReturns true if a Duration is greater than or equal to minimum and less than or equal to maximum, according to Duration.Order.equalsconstChecks whether two Durations are equal.isGreaterThanconstChecks whether the first Duration is greater than the second.isGreaterThanOrEqualToconstChecks whether the first Duration is greater than or equal to the second.isLessThanconstChecks whether the first Duration is less than the second.isLessThanOrEqualToconstChecks whether the first Duration is less than or equal to the second.