Skip to content

Commit 9c52d80

Browse files
committed
use timezone.now() to get current time
1 parent a7ae2ee commit 9c52d80

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

appointment/views.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66
Since: 1.0.0
77
"""
88

9-
from datetime import date, datetime, timedelta
9+
from datetime import date, timedelta
1010

11-
import pytz
12-
from django.conf import settings
1311
from django.contrib import messages
1412
from django.contrib.auth import login
1513
from django.contrib.auth.forms import SetPasswordForm
1614
from django.db.models import Q
1715
from django.http import HttpResponseRedirect
1816
from django.shortcuts import get_object_or_404, redirect, render
1917
from django.urls import reverse
18+
from django.utils import timezone
2019
from django.utils.encoding import force_str
2120
from django.utils.http import urlsafe_base64_decode
2221
from django.utils.timezone import get_current_timezone_name
@@ -44,7 +43,7 @@
4443
from .messages_ import passwd_error, passwd_set_successfully
4544
from .services import get_appointments_and_slots, get_available_slots_for_staff
4645
from .settings import (APPOINTMENT_PAYMENT_URL, APPOINTMENT_THANK_YOU_URL)
47-
from .utils.date_time import convert_str_to_date, convert_str_to_time
46+
from .utils.date_time import convert_str_to_date
4847
from .utils.error_codes import ErrorCode
4948
from .utils.json_context import get_generic_context_with_extra, json_response
5049

@@ -97,7 +96,7 @@ def get_available_slots_ajax(request):
9796

9897
# Check if the selected_date is today and filter out past slots
9998
if selected_date == date.today():
100-
current_time = datetime.now(pytz.timezone(settings.TIME_ZONE)).time()
99+
current_time = timezone.now().time()
101100
available_slots = [slot for slot in available_slots if slot.time() > current_time]
102101

103102
custom_data['available_slots'] = [slot.strftime('%I:%M %p') for slot in available_slots]

0 commit comments

Comments
 (0)