Fixed incorrect logic in how weekly reset date is picked, choose the most recent previous day, not the closest
This commit is contained in:
@@ -113,7 +113,7 @@
|
||||
/// <param name="dateTime">Date to get closest monday of</param>
|
||||
/// <param name="startDay">Starting day of week - Default = Monday</param>
|
||||
/// <returns>Monday as DateTime</returns>
|
||||
public static DateTime GetStartOfWeek(
|
||||
public static DateTime GetClosestDate(
|
||||
this DateTime dateTime,
|
||||
DayOfWeek startDay = DayOfWeek.Monday
|
||||
)
|
||||
@@ -124,5 +124,29 @@
|
||||
// Subtract difference to get date of most recent Monday
|
||||
return dateTime.AddDays(-1 * diff).Date;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the most recent requested day from date
|
||||
/// </summary>
|
||||
/// <param name="dateTime">Date to start from</param>
|
||||
/// <param name="desiredDay">Desired day to find</param>
|
||||
/// <param name="inclusiveOfToday">Should today be included in check, default = true</param>
|
||||
/// <returns>Datetime of desired day</returns>
|
||||
public static DateTime GetMostRecentPreviousDay(
|
||||
this DateTime dateTime,
|
||||
DayOfWeek desiredDay,
|
||||
bool inclusiveOfToday = true
|
||||
)
|
||||
{
|
||||
// Go back 1 day if we don't count today (exclusive)
|
||||
var closestDate = inclusiveOfToday ? dateTime : dateTime.AddDays(-1);
|
||||
|
||||
while (closestDate.DayOfWeek != desiredDay)
|
||||
{
|
||||
closestDate = closestDate.AddDays(-1);
|
||||
}
|
||||
|
||||
return closestDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class PostDbLoadService(
|
||||
protected WildSpawnType GetWeeklyBoss(List<WildSpawnType> bosses, DayOfWeek bossResetDay)
|
||||
{
|
||||
// Get closest monday to today
|
||||
var startOfWeek = DateTime.Today.GetStartOfWeek(bossResetDay);
|
||||
var startOfWeek = DateTime.Today.GetMostRecentPreviousDay(bossResetDay);
|
||||
|
||||
// Create a consistent seed for the week using the year and the day of the year of above monday chosen
|
||||
// This results in seed being identical for the week
|
||||
|
||||
Reference in New Issue
Block a user