From a60a34286483c234889a234026d6b26bf8e695f1 Mon Sep 17 00:00:00 2001 From: Johann Kellerman Date: Thu, 14 Jul 2016 03:45:55 +0200 Subject: [PATCH] Logbook: Query databse as_utc(). dt: Use pytz's localize (#2521) --- homeassistant/components/logbook.py | 1 + homeassistant/util/dt.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/logbook.py b/homeassistant/components/logbook.py index 433dd468c63..c6cec168aed 100644 --- a/homeassistant/components/logbook.py +++ b/homeassistant/components/logbook.py @@ -94,6 +94,7 @@ class LogbookView(HomeAssistantView): else: start_day = dt_util.start_of_local_day() + start_day = dt_util.as_utc(start_day) end_day = start_day + timedelta(days=1) events = recorder.get_model('Events') diff --git a/homeassistant/util/dt.py b/homeassistant/util/dt.py index a875087fed6..b8b7a691859 100644 --- a/homeassistant/util/dt.py +++ b/homeassistant/util/dt.py @@ -92,8 +92,7 @@ def start_of_local_day(dt_or_d=None): elif isinstance(dt_or_d, dt.datetime): dt_or_d = dt_or_d.date() - return dt.datetime.combine(dt_or_d, dt.time()).replace( - tzinfo=DEFAULT_TIME_ZONE) + return DEFAULT_TIME_ZONE.localize(dt.datetime.combine(dt_or_d, dt.time())) # Copyright (c) Django Software Foundation and individual contributors.