From 7a00bf869652df90687f77e441e35a353e54296c Mon Sep 17 00:00:00 2001 From: Ryan Kraus Date: Sat, 6 Feb 2016 21:31:07 -0500 Subject: [PATCH] Fixed time zone conversion with no TZ specified Using .replace to set the current time zone appears to not handle things correctly. The proper way to do this is apparently .localize. --- homeassistant/util/dt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/util/dt.py b/homeassistant/util/dt.py index a2c796c20eb..604777399ec 100644 --- a/homeassistant/util/dt.py +++ b/homeassistant/util/dt.py @@ -48,7 +48,7 @@ def as_utc(dattim): if dattim.tzinfo == UTC: return dattim elif dattim.tzinfo is None: - dattim = dattim.replace(tzinfo=DEFAULT_TIME_ZONE) + dattim = DEFAULT_TIME_ZONE.localize(dattim) return dattim.astimezone(UTC) @@ -58,7 +58,7 @@ def as_local(dattim): if dattim.tzinfo == DEFAULT_TIME_ZONE: return dattim elif dattim.tzinfo is None: - dattim = dattim.replace(tzinfo=UTC) + dattim = UTC.localize(dattim) return dattim.astimezone(DEFAULT_TIME_ZONE)