feat: time tracking in minutes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user