GW2PAO.API.Services.EventsService.GetTimeSinceActive C# (CSharp) Méthode

GetTimeSinceActive() public méthode

Retrieves the amount of time since the last active time for the given event, using the megaserver timetables
public GetTimeSinceActive ( WorldBossEvent evt ) : System.TimeSpan
evt GW2PAO.API.Data.Entities.WorldBossEvent The event to retrieve the time for
Résultat System.TimeSpan
        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;
        }
    }

Usage Example

        public void EventsService_GetState_GetTimeSinceActive_Null_Invalid()
        {
            EventsService es = new EventsService();

            var timeUntilActive = es.GetTimeSinceActive(null);

            Assert.AreEqual(TimeSpan.MinValue, timeUntilActive);
        }
All Usage Examples Of GW2PAO.API.Services.EventsService::GetTimeSinceActive