Skip to content

Commit

Permalink
Fix failing tests when local time zone has DST, #1133 (#1137)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirwin authored Mar 9, 2025
1 parent 4c19e5d commit 690b175
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Lucene.Net.TestFramework/Index/AlcoholicMergePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public class AlcoholicMergePolicy : LogMergePolicy
public AlcoholicMergePolicy(TimeZoneInfo timeZone, Random random)
{
// LUCENENET NOTE: All we care about here is that we have a random distribution of "Hour", picking any valid
// date at random achives this. We have no actual need to create a Calendar object in .NET.
var randomTime = new DateTime(TestUtil.NextInt64(random, DateTime.MinValue.Ticks, DateTime.MaxValue.Ticks));
this.calendar = TimeZoneInfo.ConvertTime(randomTime, TimeZoneInfo.Local, timeZone);
// date at random achieves this. We have no actual need to create a Calendar object in .NET.
var randomTicks = TestUtil.NextInt64(random, DateTime.MinValue.Ticks, DateTime.MaxValue.Ticks);
var randomTime = new DateTime(randomTicks);
this.calendar = TimeZoneInfo.ConvertTime(randomTime, TimeZoneInfo.Utc, timeZone);
this.random = random;
m_maxMergeSize = TestUtil.NextInt32(random, 1024 * 1024, int.MaxValue);
}
Expand Down Expand Up @@ -73,4 +74,4 @@ private enum Drink
SingleMalt = 30
}
}
}
}

0 comments on commit 690b175

Please sign in to comment.