EDIT: This was a bit rewitten as I didn't read the entire thread before writing this.
In cyran0's script this section is used to find the remainder when storeCurrentDay is divided by 7. In other words it is a simple way of preforming a modulo operation.
while ( storeCurrentDay >= 8 ) set storeCurrentDay to ( storeCurrentDay - 7 )endwhile
Unfortunately Morrowind doesn't have a modulo function, however it is possible with some simple maths to implement something similar that avoids the while loop (imagine in days passed was 30,000. The while loop would have to execute 4285 times!)
Taking the first day of the week as being 0, it is obvious that:
DaysPassed = weekNum * 7 + WeekDay [1]
As we know that WeekDay < 7:
WeekNum = floor(DaysPassed/7) [2]
Therefore, rearranging equation [1] and substituting in [2] gives
WeekDay = DaysPassed - WeekNum*7 = DaysPassed - floor(DaysPassed/7)*7 [3]
I might be a bit out, so there may need to be the odd correction to that, but something similar should work. cyran0 said that when converting from a real number to an integer, Morrowind trunicates the number. So if we converted 3.95 into an integer it would be 3. So converting from an float to a short (integer) has the same effect as a floor function.
So for example:
float xshort yset x to 3.9set y to x ;convert 3.9 to an integer;y is now 3
Converting the equation [3] into Morrowind code
short weekDayshort weekNumset weekNum to ( DaysPassed / 7 ) ;=> floor(DaysPassed/7), as we are converting the result into a shortset weekDay to ( DaysPassed - ( weekNum * 7 ) )