add some hap methods for time introspection
This commit is contained in:
parent
2e8ae38d33
commit
1a0dff4081
1 changed files with 18 additions and 0 deletions
|
|
@ -49,6 +49,24 @@ export class Hap {
|
||||||
return this.whole.begin.add(this.duration);
|
return this.whole.begin.add(this.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isActive(currentTime) {
|
||||||
|
return this.whole.begin <= currentTime && this.endClipped > currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
isInPast(currentTime) {
|
||||||
|
return currentTime > this.endClipped;
|
||||||
|
}
|
||||||
|
isInNearPast(margin, currentTime) {
|
||||||
|
return currentTime - margin <= this.endClipped;
|
||||||
|
}
|
||||||
|
|
||||||
|
isInFuture(currentTime) {
|
||||||
|
return currentTime < this.whole.begin;
|
||||||
|
}
|
||||||
|
isInNearFuture(margin, currentTime) {
|
||||||
|
return currentTime < this.whole.begin && currentTime > this.whole.begin - margin;
|
||||||
|
}
|
||||||
|
|
||||||
wholeOrPart() {
|
wholeOrPart() {
|
||||||
return this.whole ? this.whole : this.part;
|
return this.whole ? this.whole : this.part;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue