mirror of https://github.com/snachodog/mybuddy.git
Merge pull request #144 from phardy/master
Ensure date passed to nap filter is localtime.
This commit is contained in:
commit
e2f432f92c
|
@ -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'],
|
||||||
|
|
Loading…
Reference in New Issue