import { useState, useEffect } from 'react';
import { parse } from 'date-fns';
export default function useTimeValue(defaultValue, value) {
    var _a = useState(value !== null && value !== void 0 ? value : defaultValue), selected = _a[0], setSelected = _a[1];
    useEffect(function () {
        setSelected(value !== null && value !== void 0 ? value : defaultValue);
    }, [value, defaultValue]);
    return { selected: selected, setSelected: setSelected };
}
export function parseSelectedToRangeDate(value, format, selectedDate) {
    return value
        ? [
            value[0] ? parse(value[0], format, selectedDate) : null,
            value[1] ? parse(value[1], format, selectedDate) : null,
        ]
        : [null, null];
}
