mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
task list api modified
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user