GitHub 6284★

Get the hours and minutes from the decimal time

JavaScript version

const getHoursAndMinutes = (value) => [Math.floor(value), Math.floor((value * 60) % 60)];

TypeScript version

const getHoursAndMinutes = (value: number): [number, number] => [Math.floor(value), Math.floor((value * 60) % 60)];

Examples

getHoursAndMinutes(4.5); //[4, 30]
getHoursAndMinutes(7.89); // [7, 53]
Follow me on and to get more useful contents.