GetPersianWeekStartAndEndDates returns wrong result for "Saturday"
Closed this issue · 2 comments
rabbal commented
Summary of the issue
GetPersianWeekStartAndEndDates return previous week's start date instead of current week for Saturday. Offset calculation in GetPersianWeekStartAndEndDates should be changed like below:
var offset = -1 * (7 + ((dateTime.DayOfWeek - firstDayOfWeek) % 7));
To
var offset = -1 * ((7 + (dateTime.DayOfWeek - firstDayOfWeek)) % 7);
Example code/Steps to reproduce:
[TestMethod]
public void Test_GetPersianWeekStartAndEndDates_For_Dates_Works_Saturday()
{
var persianCalendar = new PersianCalendar();
var date = new DateTime(1398, 5, 12, persianCalendar);
var persianWeek = date.GetPersianWeekStartAndEndDates();
Assert.AreEqual(expected: new DateTime(1398, 5, 12, persianCalendar), actual: persianWeek.StartDate);
Assert.AreEqual(expected: new DateTime(1398, 5, 18, 23, 59, 59, persianCalendar), actual: persianWeek.EndDate);
}
lock commented
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.