Merge pull request #152 from KiwiTechLLC/ZBKADM-69

task list api modified
This commit is contained in:
dilipshrivastwa-kiwi
2023-08-07 18:22:20 +05:30
committed by GitHub
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