Skip to content

Task Overdue Dates Don't Show Exactly As Expected #59

@jack-bennett-osf

Description

@jack-bennett-osf

After implementing another instance of this Timeline within a project, I noticed that Task records aren't necessarily displaying in the "Upcoming & Overdue" section of the Timeline correctly.

The code itself in activityTimeline.js determines if a Task is overdue based on both Status and Date. The Date portion of this logic is comparing based on UTC time, against the Task's Activity Date (noting that this is only a Date field, not a Date/Time field).
Image

Because this is comaring against a Date only field (time defaults to 00:00 local time), it's not exactly accurate.

As an example:
If today is the 2nd of December, 2025 and I have an incomplete Task with an ActivityDate of 2025-12-02 (still the same date), this won't appear in the "Upcoming & Overdue" section of the Timeline until 1:00pm NZT (using New Zealand time since this is what I am working with). This is due to the comparison of UTC time, to the Task ActivityDate field, which has a local time of 00:00.

I would expect that an "Upcoming" Task would be anything from today's date (starting at midnight that day), not today's date from 1:00pm my local time. What if a Task actually needed to be completed before midday for instance? It would be good to show the user at the very start of the day.

As a potential fix, I would recommend something like this:

// Treat "today" as local midnight and compare date-only
if (!config.timeline__Overdue_Field__c) {
    const today = new Date();
    today.setHours(0, 0, 0, 0);  // local midnight today

    const activityDate = new Date(childRec.ActivityDate);
    activityDate.setHours(0, 0, 0, 0); // local midnight for task

    childRec.IsOverdue = !childRec.IsClosed && activityDate <= today;
}

This makes sense since ActivityDate is only ever going to be a Date field, so we should really compare Dates with set hours of midnight of that day. It also ensures that anything that is in a past date, OR today's date will appear in "Upcoming & Overdue".

Another idea is that "Upcoming" Tasks could potentially be tweaked so that they appear in a different colour to "Overdue" Tasks (I think of overdue as anything in the past and upcoming as anything that's today, or maybe tomorrow/over the next couple of days). Overdue Tasks could retain the red text colour, whereas upcoming Tasks could be orange (or something similar)? timelineItemTask.css and timelineItemTask.html display "Overdue" tasks with a specific red colour.

Lastly, I am unsure of what is defined as an "Upcoming" Task. Is it a Task that is due today? Is it a Task that is due tomorrow? Is it a Task that is due in three days time? This would also play into how the logic would be tweaked. If I put myself in the shoes of an end user, I would probably prefer that the system displayed Tasks due in the next two or three days as "Upcoming". The colour change of the text for these ones might also be helpful.

I am happy to try implement these changes in a pull request, but would be good to see if there was a reason the code was created in this way before I do so :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions