66from collections .abc import Awaitable , Callable
77from dataclasses import dataclass , field
88
9- from whenever import Time , ZonedDateTime
9+ from whenever import SYSTEM_TZ , Time , ZonedDateTime
1010
1111from sunsynk .helpers import slug
1212
@@ -90,7 +90,7 @@ class ToggleLogCallback(Callback):
9090
9191 def calc_next_run (self ) -> None :
9292 """Calculate the next run times."""
93- now = ZonedDateTime .now_in_system_tz ( )
93+ now = ZonedDateTime .now ( SYSTEM_TZ )
9494 self .next_runs = [
9595 n if n > now else n .add (days = 1 )
9696 for n in (now .replace_time (t ) for t in self .times )
@@ -101,19 +101,19 @@ def calc_next_run(self) -> None:
101101 @property
102102 def next_run0 (self ) -> int :
103103 """Return next run seconds of entry 0."""
104- return self .next_runs [0 ].timestamp_millis ( ) // 1000
104+ return self .next_runs [0 ].timestamp ( unit = "millisecond" ) // 1000
105105
106106 def __post_init__ (self ) -> None :
107107 """Init."""
108108 assert len (self .times ) > 0
109- self .next_runs = [ZonedDateTime .now_in_system_tz ( )]
109+ self .next_runs = [ZonedDateTime .now ( SYSTEM_TZ )]
110110 self .task = None # type:ignore[assignment]
111111 self .calc_next_run ()
112112 self .original_level = _LOG .level
113113
114114 async def mute_log (self ) -> None :
115115 """Set log level to critical, and reset after duration."""
116- now , _ , _ = ZonedDateTime .now_in_system_tz ( ).format_iso ().partition ("T" )
116+ now , _ , _ = ZonedDateTime .now ( SYSTEM_TZ ).format_iso ().partition ("T" )
117117 _LOG .info (
118118 "[%s] Disabling the log for %s seconds" ,
119119 now ,
@@ -184,7 +184,7 @@ async def run_callbacks(callbacks: list[Callback]) -> None:
184184 """Run the timer."""
185185 while True :
186186 now_s = 0
187- now_ms = ZonedDateTime .now_in_system_tz (). timestamp_millis ( )
187+ now_ms = ZonedDateTime .now ( SYSTEM_TZ ). timestamp ( unit = "millisecond" )
188188 for cb in callbacks :
189189 if now_ms < cb .due_at_ms ():
190190 continue
0 commit comments