Skip to content

Commit

Permalink
Fix workday timezone (#119148)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBrien authored Jun 8, 2024
1 parent a64d6e5 commit fff2c11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/workday/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def get_next_interval(self, now: datetime) -> datetime:

def _update_state_and_setup_listener(self) -> None:
"""Update state and setup listener for next interval."""
now = dt_util.utcnow()
now = dt_util.now()
self.update_data(now)
self.unsub = async_track_point_in_utc_time(
self.hass, self.point_in_time_listener, self.get_next_interval(now)
Expand Down
6 changes: 4 additions & 2 deletions tests/components/workday/test_binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Tests the Home Assistant workday binary sensor."""

from datetime import date, datetime, timedelta
from datetime import date, datetime, timedelta, timezone
from typing import Any

from freezegun.api import FrozenDateTimeFactory
Expand Down Expand Up @@ -68,7 +68,9 @@ async def test_setup(
freezer: FrozenDateTimeFactory,
) -> None:
"""Test setup from various configs."""
freezer.move_to(datetime(2022, 4, 15, 12, tzinfo=UTC)) # Friday
# Start on a Friday
await hass.config.async_set_time_zone("Europe/Paris")
freezer.move_to(datetime(2022, 4, 15, 0, tzinfo=timezone(timedelta(hours=1))))
await init_integration(hass, config)

state = hass.states.get("binary_sensor.workday_sensor")
Expand Down

0 comments on commit fff2c11

Please sign in to comment.