Replace pytz with standard library timezone (#16197)

Refactored code to use Python's built-in datetime.timezone and zoneinfo instead of pytz for timezone handling. This modernizes the codebase and removes the dependency on pytz, aligning with current best practices for timezone-aware datetime objects.
This commit is contained in:
Hao Liu
2026-01-09 16:05:08 -05:00
committed by GitHub
parent dbe979b425
commit fee71b8917
5 changed files with 23 additions and 30 deletions

View File

@@ -50,7 +50,7 @@ from rest_framework_yaml.renderers import YAMLRenderer
# ansi2html
from ansi2html import Ansi2HTMLConverter
import pytz
from datetime import timezone as dt_timezone
from wsgiref.util import FileWrapper
# django-ansible-base
@@ -648,7 +648,7 @@ class SchedulePreview(GenericAPIView):
continue
schedule.append(event)
return Response({'local': schedule, 'utc': [s.astimezone(pytz.utc) for s in schedule]})
return Response({'local': schedule, 'utc': [s.astimezone(dt_timezone.utc) for s in schedule]})
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)