diff --git a/tasks/models.py b/tasks/models.py index a88425c..142d019 100644 --- a/tasks/models.py +++ b/tasks/models.py @@ -153,14 +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 - import pytz + from zoneinfo import ZoneInfo # Get current date in user's timezone try: - user_tz = pytz.timezone(self.user.timezone) + user_tz = ZoneInfo(self.user.timezone) user_now = timezone.now().astimezone(user_tz) user_today = user_now.date() - except (pytz.UnknownTimeZoneError, AttributeError): + except (Exception,): # Fall back to UTC if user timezone is invalid or missing user_today = timezone.now().date() diff --git a/tasks/views.py b/tasks/views.py index c7ed0cb..54af7dc 100644 --- a/tasks/views.py +++ b/tasks/views.py @@ -219,12 +219,12 @@ class DashboardView(View): return redirect('login') # Get today's date in user's timezone - import pytz + from zoneinfo import ZoneInfo try: - user_tz = pytz.timezone(request.user.timezone) + user_tz = ZoneInfo(request.user.timezone) user_now = timezone.now().astimezone(user_tz) today = user_now.date() - except (pytz.UnknownTimeZoneError, AttributeError): + except (Exception,): # Fall back to UTC if user timezone is invalid or missing today = timezone.now().date()