feat: add BatteryMonitor implementation with discovery, notification, and scheduling services
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
namespace HomeAssistant.HistoryReplay.Replay;
|
||||
|
||||
public sealed class ReplayTimeProvider : TimeProvider
|
||||
{
|
||||
private readonly Lock _lock = new();
|
||||
private DateTimeOffset _currentUtcTime;
|
||||
private readonly TimeZoneInfo _localTimeZone;
|
||||
|
||||
public ReplayTimeProvider(DateTimeOffset initialTime)
|
||||
{
|
||||
_currentUtcTime = initialTime.ToUniversalTime();
|
||||
_localTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
|
||||
}
|
||||
|
||||
public override DateTimeOffset GetUtcNow()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
return _currentUtcTime;
|
||||
}
|
||||
}
|
||||
|
||||
public override TimeZoneInfo LocalTimeZone => _localTimeZone;
|
||||
|
||||
public void AdvanceTo(DateTimeOffset utcTime)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_currentUtcTime = utcTime.ToUniversalTime();
|
||||
}
|
||||
}
|
||||
|
||||
public void AdvanceBy(TimeSpan duration)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_currentUtcTime += duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user