In an aggregation pipeline, how to group records by date?

Any suggestions for how to group in an aggregation stage documents with a date field by week ending on Sunday?

For example, today is 2022-04-29, and the next week ending Sunday is 5/1; therefore, week ending Sunday 2022-05-01 represents the dates 2022-04-25 to 2022-05-01.

My approach would be to

  1. $set a new field using $dateToParts
  2. $group using the new field isoWeek

What I do not know is what is the last day of an isoWeek or if it can be changed.

However according to ISO 8601 - Wikipedia, it looks like that an isoWeek ends on Sunday.