/// <summary> /// Calculates the number of weeks represented by the current <see cref="DateSpan"/> structure. /// </summary> /// <value>Calculates the number of weeks represented by the current <see cref="DateSpan"/> structure.</value> public int GetWeeks() { TimeSpan range = Highest.Subtract(Lowest); int totalDays = 0; if (range.Days <= 7) { totalDays = Lowest.DayOfWeek > Highest.DayOfWeek ? 2 : 1; } if (totalDays == 0) { totalDays = range.Days - 7 + (int)Lowest.DayOfWeek; } int nextWeek = 0, weeks; for (weeks = 1; nextWeek < totalDays; weeks++) { nextWeek += 7; } return(weeks); }