import * as moment from 'moment';
import { getEndOfTheWeek, getStartOfTheWeek } from './date';

export function getWeek(date?: Date): [Date, Date] {
    return [getStartOfTheWeek(date), getEndOfTheWeek(date)];
}

export function isValidWeek(week?: [Date, Date]) {
    if (!week) {
        return false;
    }

    const [from, to] = week;

    if (!from || !to) {
        return false;
    }

    return !(moment(from).isoWeekday() != 1 || moment(to).isoWeekday() != 7);
}
