From f2ca07d05d823e03fd9f61d37974101db478834a Mon Sep 17 00:00:00 2001 From: Keith Smith Date: Fri, 9 Jan 2026 08:28:59 -0700 Subject: [PATCH] Fix overdue calculation to use user's timezone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tasks were incorrectly showing as overdue when they were due today. The issue was that the overdue check was comparing the due date against UTC's "today" instead of the user's local "today". Now uses the user's timezone setting to determine the current date when checking if a task is overdue. This ensures tasks due "today" only become overdue when the user's local date advances to tomorrow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- tasks/models.py | 9 ++++++++- tasks/views.py | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tasks/models.py b/tasks/models.py index 28db6a4..66e0b0a 100644 --- a/tasks/models.py +++ b/tasks/models.py @@ -153,7 +153,14 @@ class Task(models.Model): """Check if task is overdue.""" if self.due_date and self.status not in ('completed', 'cancelled'): from django.utils import timezone - return self.due_date < timezone.now().date() + import pytz + + # Get current date in user's timezone + user_tz = pytz.timezone(self.user.timezone) + user_now = timezone.now().astimezone(user_tz) + user_today = user_now.date() + + return self.due_date < user_today return False @property diff --git a/tasks/views.py b/tasks/views.py index 673eda9..a8ba166 100644 --- a/tasks/views.py +++ b/tasks/views.py @@ -218,7 +218,11 @@ class DashboardView(View): if not request.user.is_authenticated: return redirect('login') - today = timezone.now().date() + # Get today's date in user's timezone + import pytz + user_tz = pytz.timezone(request.user.timezone) + user_now = timezone.now().astimezone(user_tz) + today = user_now.date() # Get filter parameters current_filter = request.GET.get('filter', 'all')