lastDayOfWeek method
Returns a new DateTime
on Sunday of the current week.
Implementation
static DateTime lastDayOfWeek(DateTime day) {
// Handle Daylight Savings by setting hour to 12:00 Noon
// rather than the default of Midnight
day = new DateTime.utc(day.year, day.month, day.day, 12);
// Weekday is on a 1-7 scale Monday - Sunday,
// This Calendar's Week starts on Sunday
return day.add(new Duration(days: 7 - (day.weekday % 7)));
}