diff --git a/src/Raven.Server/Documents/Queries/Results/TimeSeries/TimeSeriesRetriever.cs b/src/Raven.Server/Documents/Queries/Results/TimeSeries/TimeSeriesRetriever.cs index 95c798a7cebf..f6ac558e6b0e 100644 --- a/src/Raven.Server/Documents/Queries/Results/TimeSeries/TimeSeriesRetriever.cs +++ b/src/Raven.Server/Documents/Queries/Results/TimeSeries/TimeSeriesRetriever.cs @@ -771,7 +771,7 @@ string GetSourceAndId() private static RangeGroup InitializeRangeSpecs(string groupByTimePeriod, DateTime from, DateTime to, TimeSpan? offset) { - TimeSeriesReader.AddOffsetIfNeeded(offset, ref from, ref to); + (from, to) = TimeSeriesReader.AddOffsetIfNeeded(offset, from, to); if (groupByTimePeriod != null) return RangeGroup.ParseRangeFromString(groupByTimePeriod, from); diff --git a/src/Raven.Server/Documents/TimeSeries/TimeSeriesReader.cs b/src/Raven.Server/Documents/TimeSeries/TimeSeriesReader.cs index addea3452f87..2c6e22520faa 100644 --- a/src/Raven.Server/Documents/TimeSeries/TimeSeriesReader.cs +++ b/src/Raven.Server/Documents/TimeSeries/TimeSeriesReader.cs @@ -159,7 +159,7 @@ internal bool Init() return false; } - AddOffsetIfNeeded(_offset, ref _from, ref _to); + (_from, _to) = AddOffsetIfNeeded(_offset, _from, _to); return true; } @@ -619,31 +619,26 @@ internal string GetCurrentSegmentChangeVector() return (etag, changeVector, baseline); } - internal static void AddOffsetIfNeeded(TimeSpan? offset, ref DateTime from, ref DateTime to) + internal static (DateTime From, DateTime To) AddOffsetIfNeeded(TimeSpan? offset, DateTime from, DateTime to) { if (offset.HasValue == false) - return; + return (from, to); - AddOffset(offset.Value, ref from); - AddOffset(offset.Value, ref to); + from = AddOffset(offset.Value, from); + to = AddOffset(offset.Value, to); + return (from, to); } - private static void AddOffset(TimeSpan offset, ref DateTime date) + private static DateTime AddOffset(TimeSpan offset, DateTime date) { var withOffset = date.Ticks + offset.Ticks; if (withOffset < 0) - { - date = DateTime.MinValue; - return; - } - + return DateTime.MinValue; + if (withOffset > DateTime.MaxValue.Ticks) - { - date = DateTime.MaxValue; - return; - } - - date = date.Add(offset); + return DateTime.MaxValue; + + return date.Add(offset); } }