compare duration
This commit is contained in:
parent
4e7967dbac
commit
08746f5bf0
@ -216,6 +216,29 @@ export namespace Duration {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two durations. Returns 0 when equal, -1 when a < b
|
||||
* and +1 when a > b.
|
||||
*/
|
||||
export function cmp(d1: Duration, d2: Duration): 1 | 0 | -1 {
|
||||
if (d1.d_ms === "forever") {
|
||||
if (d2.d_ms === "forever") {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (d2.d_ms === "forever") {
|
||||
return -1;
|
||||
}
|
||||
if (d1.d_ms == d2.d_ms) {
|
||||
return 0;
|
||||
}
|
||||
if (d1.d_ms > d2.d_ms) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
export function max(d1: Duration, d2: Duration): Duration {
|
||||
return durationMax(d1, d2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user