User:Sunmarsh/Sandbox/Orange

{| style="border:4px solid #; background-color:#; ;" ! colspan=5 style="height:55px; padding:5px 0 0 0;"| ! width=125px | Sunday ! width=125px | Monday ! width=125px | Tuesday ! width=125px | Wednesday ! width=125px | Thursday ! width=125px | Friday ! width=125px | Saturday
 * style="text-align:center; height:55px;"|
 * style="text-align:center; height:55px;"|
 * colspan=7 style="border-bottom: 2px solid #;" |
 * colspan=7 style="border-bottom: 2px solid #;" |
 * colspan=7 style="padding:0px; border-bottom: 2px solid #;" |
 * colspan=7 style="padding:0px; border-bottom: 2px solid #;" |






 * ffffff; ;" |
 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * ffffff; ;" |
 * ffffff; ;" |


 * }

Calculate the difference between calendar value x and the start date value (numeral associated with the day of the week the month starts on), and add 1. If the result of this expression is less than one, then the calendar value is part of the previous month. For these calendar values, take the number of days in the previous month and add to them the result of the following expression: calendar value x - the start date value + 1. If the result of the expression in the first sentence is 1 or greater then determine if calendar value x is equal to or greater than the sum of the number of days in the current month and the start date value. If so, then the calendar value is part of the following month. For these calendar values, subtract the sum of the number of days in the current month and the start date value from calendar value x and add 1. For all other values (the calendar values associated with the days of the current month), calculate the difference between calendar value x and the start date value and add 1.

To determine whether or not the calendar should display a given week, find the sum of these variables: the number of days in the current month, the start date value, and six minus the end date value. Whether or not the week is displayed is dependent on whether this value exceeds 28 (for a fifth week), and then 35 (for a sixth week).