public TimeSpan GetTimeSinceActive(WorldBossEvent evt)
{
TimeSpan timeSinceActive = TimeSpan.MinValue;
if (evt != null)
{
// Find the next time
var lastTime = evt.ActiveTimes.LastOrDefault(activeTime => (this.timeProvider.CurrentTime.TimeOfDay - activeTime.Time) >= TimeSpan.FromSeconds(0));
// If there is no next time, then take the first time
if (lastTime == null)
{
lastTime = evt.ActiveTimes.FirstOrDefault();
if (lastTime != null)
timeSinceActive = (this.timeProvider.CurrentTime.TimeOfDay - lastTime.Time) + TimeSpan.FromHours(24);
}
else
{
// Calculate the number of seconds until the next time
timeSinceActive = this.timeProvider.CurrentTime.TimeOfDay - lastTime.Time;
}
}
return timeSinceActive;
}
}