import { default } from "https://deno.land/x/duration@1.0.1/mod.ts";
A span of time as 2^31-1 seconds.
Duration
is complete successor of dart's Duration class.
Duration is not depends on Date, Timezone. Duration based on microseconds, You can convert to days, hours, minutes, seconds, milliseconds and microseconds itself.
To create a new Duration object, use single constructor giving the appropriate arguments:
Duration fastestMarathon = new Duration({hours:2, minutes:3, seconds:2});
The Duration is sum of all individual parts notice above.
assert(fastestMarathon === 123);
The parts of Duration can be a negative one.
Duration has arithmetic and compare method, You can add, subtract, multiply, divide and compare like >, <, >=, <=.
Properties
Methods
Compares this Duration to other, returning zero if the values are equal.
const duration1 = new Duration({ days: 2 });
const duration2 = new Duration({ days: 1 });
assert(duration1.compareTo(duration2) === 1)
const duration1 = new Duration({ days: 1 });
const duration2 = new Duration({ days: 2 });
assert(duration1.compareTo(duration2) === -1)
const duration1 = new Duration({ days: 1 });
const duration2 = new Duration({ days: 1 });
assert(duration1.compareTo(duration2) === 0)
Returns true if this Duration is less than equal with other Duration
Returns true if this Duration is greater than equal with other Duration