refactor: format now static
This commit is contained in:
parent
757d982f71
commit
67ef5ff17a
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user