Extension method to get the Sunday date from current date based on weekOffset I want to write an extension method for getting Sunday Date based on weekOffset and current date. For example if weekOffset value is 1 that means next week sunday date and if weekOffset is 2 that means next to next week's Sunday date.
I have come up with below code
private static List&lt;string&gt; GetWeekRange(this DateTimeOffset date, int weekOffset = 0)
        {
            var sundayDate = new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, date.Offset).AddDays(weekOffset * 7 - (int) new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, date.Offset).DayOfWeek);
            var saturdayDate = new DateTimeOffset(weekStartDate.Year, weekStartDate.Month, weekStartDate.Day, 0, 0, 0, weekStartDate.Offset).AddDays(7).AddMilliseconds(-1);
            return new List&lt;string&gt; { weekStartDate.ToString(&quot;o&quot;), weekEndDate.ToString(&quot;o&quot;) };
        }

I was wondering if there can be a better way to do this?
I think your code could be more succinctly and usefully (ie don't return string) written as:
    private static DateTimeOffset[] GetWeekRange(this DateTimeOffset d, int weekOffset = 0)
    {
        var weekStartDate = new DateTimeOffset(d.Date, d.Offset).AddDays(weekOffset * 7 - (int)d.DayOfWeek);
        var weekEndDate = weekStartDate.AddDays(7);
        return new [] { weekStartDate, weekEndDate };
    }

But then given that end is so easily calc'd from start, maybe just return start, forget the array