Ensure date passed to filter is localtime.

This commit is contained in:
Peter Hardy 2020-05-18 23:07:11 +10:00
parent 7fdc358533
commit 120cbf35b6
1 changed files with 3 additions and 2 deletions

View File

@ -148,8 +148,9 @@ def card_sleep_naps_day(child, date=None):
:param date: a Date object for the day to filter. :param date: a Date object for the day to filter.
:returns: a dictionary of nap data statistics. :returns: a dictionary of nap data statistics.
""" """
date = timezone.localtime(date).astimezone(timezone.utc) if not date:
instances = models.Sleep.naps.filter(child=child, start__date=date.date()) date = timezone.localtime().date()
instances = models.Sleep.naps.filter(child=child, start__date=date)
return { return {
'type': 'sleep', 'type': 'sleep',
'total': instances.aggregate(Sum('duration'))['duration__sum'], 'total': instances.aggregate(Sum('duration'))['duration__sum'],