From ba8d429a9f7d4ce7d0912d252971911658278a0f Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sun, 31 May 2015 22:54:16 +0200 Subject: [PATCH] add timestamp to short time --- homeassistant/util/dt.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/util/dt.py b/homeassistant/util/dt.py index fbe00c85527..f3c96368667 100644 --- a/homeassistant/util/dt.py +++ b/homeassistant/util/dt.py @@ -108,6 +108,14 @@ def str_to_datetime(dt_str): except ValueError: # If dt_str did not match our format return None +def timestamp_to_short_time_str(timestamp): + """ Converts a UNIX timestamp to a short time string format. + + @rtype: str + """ + return dt.datetime.fromtimestamp( + int(timestamp)).strftime(TIME_SHORT_STR_FORMAT) + def strip_microseconds(dattim): """ Returns a copy of dattime object but with microsecond set to 0. """