updated method for finding "overdue"

This commit is contained in:
Suraj 2016-03-01 00:09:48 +05:30
parent 7a0b369dcb
commit 5119a5d91f
1 changed files with 7 additions and 5 deletions

View File

@ -118,12 +118,14 @@ func GetTasks(status, category string) (types.Context, error) {
}
TaskCreated = TaskCreated.Local()
if task.Priority != "1" { // if priority is not 1 then calculate, else why bother?
CurrentTime := time.Now().Local()
week := TaskCreated.AddDate(0, 0, 7)
if (week.String() < CurrentTime.String()) && (task.Priority != "1") {
diff := CurrentTime.Sub(TaskCreated).Hours()
log.Println(diff)
if diff > 168 {
task.IsOverdue = true // If one week then overdue by default
}
}
task.Created = TaskCreated.Format("Jan 01 2006")
tasks = append(tasks, task)