import { TimeWindow } from 'apps/sales/src/app/modules/task-calendar/defs';
import { parseStringDate } from 'apps/sales/src/app/modules/task-calendar/utils';

export function fromTimeToTimeWindow(timeTo: string, timeFrom: string): TimeWindow {
  const startDate = parseStringDate(timeTo);
  const endDate = parseStringDate(timeFrom);

  if (!timeTo || !timeFrom) {
    return null;
  }

  return {
    from: {
      hours: startDate.getHours(),
      minutes: startDate.getMinutes(),
    },
    to: {
      hours: endDate.getHours(),
      minutes: endDate.getMinutes(),
    },
  };
}
