mirror of https://github.com/snachodog/mybuddy.git
Ensure date passed to filter is localtime.
This commit is contained in:
parent
7fdc358533
commit
120cbf35b6
|
@ -148,8 +148,9 @@ def card_sleep_naps_day(child, date=None):
|
|||
:param date: a Date object for the day to filter.
|
||||
:returns: a dictionary of nap data statistics.
|
||||
"""
|
||||
date = timezone.localtime(date).astimezone(timezone.utc)
|
||||
instances = models.Sleep.naps.filter(child=child, start__date=date.date())
|
||||
if not date:
|
||||
date = timezone.localtime().date()
|
||||
instances = models.Sleep.naps.filter(child=child, start__date=date)
|
||||
return {
|
||||
'type': 'sleep',
|
||||
'total': instances.aggregate(Sum('duration'))['duration__sum'],
|
||||
|
|
Loading…
Reference in New Issue