export class Clock {
constructor(h, m = 0) {
let total = (h * 60 + m) % 1440;
if (total < 0) total += 1440;
this.m = total;
}
toString() {
const h = Math.floor(this.m / 60).toString().padStart(2, '0');
const m = (this.m % 60).toString().padStart(2, '0');
return h + ':' + m;
}
plus(m) { return new Clock(0, this.m + m); }
minus(m) { return new Clock(0, this.m - m); }
equals(other) { return this.m === other.m; }
}