HDateTimeRange.thisWeek constructor

HDateTimeRange.thisWeek(
  1. HTimeZone tz
)

Make a range which encompasses the current week.

The week is defined as Sunday thru Saturday.

Implementation

factory HDateTimeRange.thisWeek(HTimeZone tz) {
  HDate today = HDate.today(tz);
  HDate sun = today.minusDays(today.weekday() - DateTime.monday);
  HDate sat = today.plusDays(DateTime.sunday - today.weekday());
  return HDateTimeRange.datesAndTZ(sun, sat, tz);
}