feat: time tracking in minutes

This commit is contained in:
2024-11-22 21:43:07 +04:00
parent 20616d9e81
commit de55f9fa1c
4 changed files with 116 additions and 49 deletions

View File

@@ -42,3 +42,18 @@ export function ObjectStateToTableProps<T extends MRT_RowData>(
onCreate: state.onCreate,
};
}
export const floatHoursToHoursAndMinutes = (hours: number): number[] => {
const resHours = Math.floor(hours);
const minutes = Math.round((hours - resHours) * 60);
return [resHours, minutes];
};
export const strTimeToFloatHours = (time: string): number => {
const values = time.split(":");
if (values.length !== 2) return -1;
const hours = parseInt(values[0]);
const minutes = parseInt(values[1]);
return hours + minutes / 60;
}