export const dateInRange = (currentDate: string, startDate: string, endDate: string) => {

    if (currentDate === undefined) {
        return false // can be changed to true if necessary
    }

    const currentDateTime = new Date(currentDate).getTime()
    const startDateTime = startDate === undefined || startDate.length === 0 ? undefined : new Date(startDate).getTime()
    const endDateTime = endDate === undefined || startDate.length === 0 ? undefined : new Date(endDate).getTime()

    // console.log(currentDateTime, startDateTime, endDateTime)
    if (startDateTime === undefined && endDateTime !== undefined) {
        return currentDateTime <= endDateTime
    } else if (startDateTime !== undefined && endDateTime === undefined) {
        return currentDateTime >= startDateTime
    } else {
        if (startDateTime !== undefined && endDateTime !== undefined) {
            return currentDateTime >= startDateTime && currentDateTime <= endDateTime
        } else {
            return true
        }
    }
}

export const downloadFile = (blobData: Uint8Array, filename: string) => {
    const url = URL.createObjectURL(new Blob([blobData]));
    const link = document.createElement("a");
    link.href = url;
    link.setAttribute("download", filename);
    link.click();
}