Fix overdue calculation to use user's timezone

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 <noreply@anthropic.com>
This commit is contained in:
Keith Smith
2026-01-09 08:28:59 -07:00
co-authored by Claude Sonnet 4.5
parent c994458e24
commit f2ca07d05d
2 changed files with 13 additions and 2 deletions
+8 -1
View File
@@ -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
+5 -1
View File
@@ -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')