fix(date-time-utils): fix rounding error in util method that converts hours float to HHmm string
This commit is contained in:
parent
e44d790a21
commit
42de823b87
|
|
@ -21,7 +21,13 @@ export const getMinutes = (hours: number) => {
|
|||
}
|
||||
|
||||
export const getHoursMinutesStringFromHoursFloat = (hours: number): string => {
|
||||
const flat_hours = Math.floor(hours);
|
||||
const minutes = Math.round((hours - flat_hours) * 60);
|
||||
let flat_hours = Math.floor(hours);
|
||||
let minutes = Math.round((hours - flat_hours) * 60);
|
||||
|
||||
if (minutes === 60) {
|
||||
flat_hours += 1;
|
||||
minutes = 0;
|
||||
}
|
||||
|
||||
return `${flat_hours}h${minutes > 1 ? ' ' + minutes : ''}`
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user