1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Add as_local convenience function to jinja templates (#39618)

This commit is contained in:
J. Nick Koston
2020-09-03 14:35:16 -05:00
committed by GitHub
parent a9cc882394
commit 35e84d0427
2 changed files with 15 additions and 0 deletions

View File

@@ -511,6 +511,19 @@ def test_timestamp_local(hass):
)
def test_as_local(hass):
"""Test converting time to local."""
hass.states.async_set("test.object", "available")
last_updated = hass.states.get("test.object").last_updated
assert template.Template(
"{{ as_local(states.test.object.last_updated) }}", hass
).async_render() == str(dt_util.as_local(last_updated))
assert template.Template(
"{{ states.test.object.last_updated | as_local }}", hass
).async_render() == str(dt_util.as_local(last_updated))
def test_to_json(hass):
"""Test the object to JSON string filter."""