fix attempt for tournaments in progress in other timezones

apikeys
Laurent 4 months ago
parent a655471384
commit b7e22ddfae
  1. 25
      tournaments/models/tournament.py

@ -1014,22 +1014,25 @@ class Tournament(BaseModel):
return self.has_started(hour_delta=hour_delta)
def supposedly_in_progress(self):
end = self.start_date + timedelta(days=self.day_duration + 1)
return self.start_date <= timezone.now() <= end
# end = self.start_date + timedelta(days=self.day_duration + 1)
# return self.start_date.replace(hour=0, minute=0) <= timezone.now() <= end
timezoned_datetime = self.local_start_date()
end = timezoned_datetime + timedelta(days=self.day_duration + 1)
now_utc = timezone.now()
now = now_utc.astimezone(self.timezone())
start = timezoned_datetime.replace(hour=0, minute=0)
# timezoned_datetime = self.local_start_date()
# end = timezoned_datetime + timedelta(days=self.day_duration + 1)
# now_utc = timezone.now()
# now = now_utc.astimezone(self.timezone())
# start = timezoned_datetime.replace(hour=0, minute=0)
# print(f"timezoned_datetime: {timezoned_datetime}")
# print(f"tournament end date: {end}")
# print(f"current time: {now}")
# print(f"tournament start: {start}")
# print(f"start <= now <= end: {start <= now <= end}")
# # print(f"timezoned_datetime: {timezoned_datetime}")
# # print(f"tournament end date: {end}")
# # print(f"current time: {now}")
# # print(f"tournament start: {start}")
# # print(f"start <= now <= end: {start <= now <= end}")
return start <= now <= end
# return start <= now <= end
def starts_in_the_future(self):
# tomorrow = datetime.now().date() + timedelta(days=1)

Loading…
Cancel
Save