Skip to content

Commit

Permalink
exclude expired tasks from date filters
Browse files Browse the repository at this point in the history
  • Loading branch information
HectorVilas committed Jan 14, 2023
1 parent 8027199 commit 9a431ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/modules/todoHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export const todoHandler = (() => {
const filtered = { title: "Tasks for this week", todos: []};
local.forEach((thisProject, projectIdx) => thisProject.todos.forEach((thisTodo, todoIdx) => {
const formatDate = thisTodo.dateDue.split("-").join(",");
if(isThisWeek(new Date(formatDate))){
if(isFuture(new Date(formatDate))
&&isThisWeek(new Date(formatDate))){
thisTodo.projectIdx = projectIdx;
thisTodo.todoIdx = todoIdx;
filtered.todos.push(thisTodo);
Expand All @@ -160,7 +161,8 @@ export const todoHandler = (() => {
const filtered = { title: "Tasks for this month", todos: []};
local.forEach((thisProject, projectIdx) => thisProject.todos.forEach((thisTodo, todoIdx) => {
const formatDate = thisTodo.dateDue.split("-").join(",");
if(isThisMonth(new Date(formatDate))){
if(isFuture(new Date(formatDate))
&&isThisMonth(new Date(formatDate))){
thisTodo.projectIdx = projectIdx;
thisTodo.todoIdx = todoIdx;
filtered.todos.push(thisTodo);
Expand All @@ -174,7 +176,8 @@ export const todoHandler = (() => {

local.forEach((thisProject, projectIdx) => thisProject.todos.forEach((thisTodo, todoIdx) => {
const formatDate = thisTodo.dateDue.split("-").join(",");
if(isThisYear(new Date(formatDate))){
if(isFuture(new Date(formatDate))
&&isThisYear(new Date(formatDate))){
thisTodo.projectIdx = projectIdx;
thisTodo.todoIdx = todoIdx;
filtered.todos.push(thisTodo);
Expand Down

0 comments on commit 9a431ae

Please sign in to comment.