task list api modified

This commit is contained in:
abutalib-kiwi
2023-08-03 18:17:01 +05:30
parent f2cf1488e9
commit dd0f2b027a
2 changed files with 63 additions and 23 deletions

View File

@ -222,9 +222,15 @@ class TaskDetailsSerializer(serializers.ModelSerializer):
def get_remaining_time(self, obj):
""" remaining time to complete task"""
import pytz
from django.utils import timezone
due_date_datetime = datetime.combine(obj.due_date, datetime.max.time())
# fetch real time
current_datetime = real_time()
# current_datetime = real_time()
print(due_date_datetime.astimezone(pytz.utc), datetime.now(pytz.utc), timezone.now().astimezone(pytz.utc))
# new code
due_date_datetime = due_date_datetime.astimezone(pytz.utc)
current_datetime = timezone.now().astimezone(pytz.utc)
# Perform the subtraction
if due_date_datetime > current_datetime:
time_difference = due_date_datetime - current_datetime