mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
add timestamp to short time
This commit is contained in:
parent
9efc357226
commit
1be50d83dc
@ -108,6 +108,14 @@ def str_to_datetime(dt_str):
|
|||||||
except ValueError: # If dt_str did not match our format
|
except ValueError: # If dt_str did not match our format
|
||||||
return None
|
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):
|
def strip_microseconds(dattim):
|
||||||
""" Returns a copy of dattime object but with microsecond set to 0. """
|
""" Returns a copy of dattime object but with microsecond set to 0. """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user