Hi,
I don't have the whole solution to your problem, but I have the piece where you can always start the week on Sunday regardless what date was picked from the DatePick or today(). For example: if 05/11/2017 picked, the week starts on Sunday 05/07/2017
Create Data type Whole Number 'NumericDayOfWeek'
Create Data type Date 'WeekOf'. Optional default value: today()
Add a rule named: getNumericDayofWeek with the follow XPath:
(number(substring(., 9, 2)) + number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) div 12))) + floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) div 12))) div 4) - floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) div 12))) div 100) + floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) div 12))) div 400) + floor((31 * number(number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) div 12)) - 2)) div 12)) mod 7
That simply get the numeric value of 'Day of Week', 0 = Sunday, 1 = Monday... Example: When you run, 'WeekOf' will have today's date of 05/11/2017. With the rule runs automatically you will get a value of 4 (Thursday). To get to the Sunday, you just need to subtract the number value from the date picked. 05/11/2017 - 4 = 05/07/2017
To achieve that you add a second rule on 'WeekOf'. We name the rule 'IfNotSunday'
Condition: If 'NumericDayOfWeek' is not 0 then run this rule:xdDate:AddDays(., -../my:NumericDayOfWeek)
That rule simply subtract itself by the numeric value of Day of Week.
To get to what you need, get the date of the Sunday + 7 or -7 to find out the date range to make sure it contains 1 or 16.
Hope that helps. Sorry if I was being wordy or not clear.