import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; dayjs.extend(utc); const defaultHourHeight = 63; const defaultHourWidth = 82; export let oneHourHeight = defaultHourHeight; export let oneHourWidth = defaultHourWidth; export const setNewHourHeight = (height = defaultHourHeight) => { oneHourHeight = Math.max(height, defaultHourHeight); }; export const setNewHourWidth = (width = defaultHourWidth) => { oneHourWidth = Math.max(width, defaultHourWidth); }; export const calculateMarginFromMinutes = (minutes: number) => { return (minutes / 60) * oneHourHeight; }; export const calculateMarginFromHours = (h: number) => { return h * oneHourHeight + 6; }; export const calculateMinutesFromHeight = (divHeight: number) => { return (60 * divHeight) / oneHourHeight; }; export const calculateMarginLeftFromMinutes = (minutes: number) => { return (minutes / 60) * oneHourWidth; }; export const calculateMarginLeftFromHours = (h: number) => { return h * oneHourWidth; }; export const calculateMinutesFromWidth = (width: number) => { return (60 * width) / oneHourWidth; }; export const getHours = (startTime: string, endTime: string) => dayjs.utc(startTime).format('hh:mm a') + ' - ' + dayjs.utc(endTime).format('hh:mm a');