public void Between() { var date = new DateTimeOffset(2015, 8, 7, 13, 26, 30, TimeSpan.Zero); Assert.IsTrue(date.Between(date.AddMonths(-3), date.AddMonths(3))); Assert.IsTrue(date.AddHours(36).Between(date.AddMonths(-3), date.AddMonths(3))); Assert.IsFalse(date.AddMonths(6).Between(date.AddMonths(-3), date.AddMonths(3))); Assert.IsFalse(date.AddHours(-2).Between(date, date.AddMonths(3))); Assert.IsTrue(date.Between(date.AddMonths(-3), date.AddMonths(3), false)); Assert.IsTrue(date.AddHours(36).Between(date.AddMonths(-3), date.AddMonths(3), false)); Assert.IsFalse(date.AddMonths(6).Between(date.AddMonths(-3), date.AddMonths(3), false)); Assert.IsTrue(date.AddHours(-2).Between(date, date.AddMonths(3), false)); Assert.IsFalse(date.AddHours(-24).Between(date, date.AddMonths(3), false)); }
Color GetEventColor(DateTimeOffset time) { if (time.Between(DateTimeOffset.Now.AddHours(2), DateTimeOffset.Now.AddMinutes(15))) { return(Colors.Yellow); } if (time.Between(DateTimeOffset.Now.AddMinutes(15), DateTimeOffset.Now.AddMinutes(-15))) { return(Colors.LimeGreen); } if (DateTimeOffset.Now.Between(time.AddMinutes(15), time.AddMinutes(45))) { return(Colors.GreenYellow); } return(Colors.Transparent); }
private void IncrementNumberOfPersons(DateTimeOffset moveTime) { if (!_lastAutoIncrement.HasValue || moveTime.Between(_lastAutoIncrement.Value).LastedLongerThen(TimeSpan.FromMilliseconds(100))) { NumberOfPersonsInArea++; } }
/// <summary> /// Try to resolve confusion in previously marked vectors /// </summary> /// <param name="currentTime"></param> /// <returns></returns> private async Task RemoveUnconfused(DateTimeOffset currentTime) { await _confusedVectors.Where(confusedVector => currentTime.Between(confusedVector.StartTime).LastedLongerThen(_motionConfiguration.ConfusionResolutionTime) && _roomService.NoMoveInStartNeighbors(confusedVector)) .ToList() .Select(async c => { await MarkVector(c.UnConfuze()); _confusedVectors.Remove(c); }) .WhenAll(); }
public (bool result, TimeSpan before, TimeSpan after) TryIncreaseBaseTime(DateTimeOffset moveTime, DateTimeOffset?lastTurnOffTime) { if (!lastTurnOffTime.HasValue || !moveTime.Between(lastTurnOffTime.Value).LastedLessThen(_motionConfiguration.MotionTimeWindow)) { return(false, _baseTime, _baseTime); } var before = _baseTime; _baseTime = _baseTime.Increase(_motionConfiguration.TurnOffTimeoutExtenderFactor); return(true, before, _baseTime); }
/// <summary> /// Check if last move in this room can be source of potential move that will be source of confusion for other moves /// </summary> /// <param name="motionTime"></param> /// <returns></returns> public MotionPoint GetConfusion(DateTimeOffset motionTime) { var lastMotion = GetLastMotion(motionTime); if (!lastMotion.CanConfuze) { return(MotionPoint.Empty); } var possibleMoveTime = motionTime.Between(lastMotion.Time.Value); if ( possibleMoveTime.IsPossible(_motionConfiguration.MotionMinDiff) && possibleMoveTime.LastedLessThen(AreaDescriptor.MotionDetectorAlarmTime) // TODO maybe increase it to 2x AreaDescriptor.MotionDetectorAlarmTime or provide distance between motion detectors ) { return(new MotionPoint(Uid, lastMotion.Time.Value)); } return(MotionPoint.Empty); }
void CheckValidityAt(DateTimeOffset usedOn) { if (!usedOn.Between(IssuedOn, ExpiresOn)) throw new Exception("Invalid credit card."); }
private void RemoveTimeOutedVectors(DateTimeOffset currentTime) { _confusedVectors.RemoveAll(confusedVector => currentTime.Between(confusedVector.EndTime).LastedLongerThen(_motionConfiguration.ConfusionResolutionTimeOut)); }