d = total days
s = start day (0-6)
t = target day (0-6)

x = ( d div 7 ) + ( ( ( ( d % 7) - ( ( ( 7 - s ) + t ) % 7 ) ) % 7 ) + 1 )

I think that's right.

d div 7 gives the number of full weeks, so the target day should be in each of those.

d % 7 gives the number of days past the last full week.

( ( ( 7 - s ) + t ) % 7 ) should give the day difference between the start day and the target day.

The difference of those two should be -6 to 6, inclusive. If it's negative, then it didn't get to the target day again. If it's non-negative, then it did.

Taking the % 7 of that difference should return -1 or 0 in the two above cases.

Adding one to that gives 0 or 1, 0 if the day wasn't reached, 1 if it was.

I haven't tested fully, but that should get you most of the way there.
_________________________
Bitt Faulk