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