I have two functions one finds this week's files and the other one finds this month's files. I want to extract/filter this week's files from this month's files.
filterThisWeek(files) {
const firstDayOfWeek = new Date(new Date().setDate(new Date().getDate() - new Date().getDay()));
return this.filterToday(files).filter((f) => {
return f.date >= firstDayOfWeek;
});
},
filterThisMonth(files) {
const today = new Date();
return files.filter((f) => {
return (
new Date(f.date).getMonth() === today.getMonth() &&
new Date(f.date).getFullYear() === today.getFullYear()
);
});
using filterThisWeek function I want to extract this week's files from this month. So filterThisMonth function should find this month's files except this week's files. I want to do it in most efficient way but I dont know how to do it.