refactor: format now static

This commit is contained in:
cha0s 2019-04-12 11:01:55 -05:00
parent 757d982f71
commit 67ef5ff17a

View File

@ -11,6 +11,18 @@ export class WorldTime {
});
}
static format(time) {
const rawHour = (time + 12) % 12;
const hour = Math.floor(0 === Math.floor(rawHour) ? 12 : rawHour);
const minutes = String(Math.floor((rawHour - Math.floor(rawHour)) * 60)).padStart(2, '0');
if (time >= 12) {
return `${hour}:${minutes} pm`;
}
else {
return `${hour}:${minutes} am`;
}
}
get hour() {
return this._hour;
}
@ -21,15 +33,6 @@ export class WorldTime {
}
humanReadable() {
const rawHour = (this._hour + 12) % 12;
const hour = Math.floor(0 === Math.floor(rawHour) ? 12 : rawHour);
const minutes = String(Math.floor((rawHour - Math.floor(rawHour)) * 60)).padStart(2, '0');
if (this._hour >= 12) {
return `${hour}:${minutes} pm`;
}
else {
return `${hour}:${minutes} am`;
}
}
patchState(steps) {