You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 line
1.3 KiB

  1. export const dateInRange = (currentDate: string, startDate: string, endDate: string) => {
  2. if (currentDate === undefined) {
  3. return false // can be changed to true if necessary
  4. }
  5. const currentDateTime = new Date(currentDate).getTime()
  6. const startDateTime = startDate === undefined || startDate.length === 0 ? undefined : new Date(startDate).getTime()
  7. const endDateTime = endDate === undefined || startDate.length === 0 ? undefined : new Date(endDate).getTime()
  8. // console.log(currentDateTime, startDateTime, endDateTime)
  9. if (startDateTime === undefined && endDateTime !== undefined) {
  10. return currentDateTime <= endDateTime
  11. } else if (startDateTime !== undefined && endDateTime === undefined) {
  12. return currentDateTime >= startDateTime
  13. } else {
  14. if (startDateTime !== undefined && endDateTime !== undefined) {
  15. return currentDateTime >= startDateTime && currentDateTime <= endDateTime
  16. } else {
  17. return true
  18. }
  19. }
  20. }
  21. export const downloadFile = (blobData: Uint8Array, filename: string) => {
  22. const url = URL.createObjectURL(new Blob([blobData]));
  23. const link = document.createElement("a");
  24. link.href = url;
  25. link.setAttribute("download", filename);
  26. link.click();
  27. }