The blue code creates a field WeekYear with weeknumber and year, like '32 - 2014'. There is some code to handle what happens if it's a broken week (the week around New Year). From what I can see:
If it's week 1 and December, it sets it to next year.
If it's week 52 or 53 January, it sets it to previous year.
There is already a solution to handle broken weeks acc. to ISO 8601, and that's to use the weekyear function.
Week(TempDate) & ' - ' & WeekYear(TempDate) As WeekYear
Also the system variable BrokenWeeks comes into play
The code in your example may have some special way of handling the broken weeks that is required. I haven't looked into how it differs from ISO 8601.
The red code sets IsLastMonth to 1 if the date is in the month before the current month.