Create common Time module and add time set cli command (#1157)

This commit is contained in:
Steven B.
2024-10-15 08:59:25 +01:00
committed by GitHub
parent 885a04d24f
commit 7fd8c14c1f
18 changed files with 350 additions and 69 deletions

View File

@@ -321,13 +321,14 @@ async def test_device_timezones():
# Get an index from a timezone
for index, zone in TIMEZONE_INDEX.items():
found_index = await get_timezone_index(zone)
zone_info = zoneinfo.ZoneInfo(zone)
found_index = await get_timezone_index(zone_info)
assert found_index == index
# Try a timezone not hardcoded finds another match
index = await get_timezone_index("Asia/Katmandu")
index = await get_timezone_index(zoneinfo.ZoneInfo("Asia/Katmandu"))
assert index == 77
# Try a timezone not hardcoded no match
with pytest.raises(zoneinfo.ZoneInfoNotFoundError):
await get_timezone_index("Foo/bar")
await get_timezone_index(zoneinfo.ZoneInfo("Foo/bar"))