code: func calcWeek(t *MysqlTime, wb weekBehaviour) (year int, week int) {
  	var days int
  	daynr := calcDaynr(int(t.year), int(t.month), int(t.day))
  	firstDaynr := calcDaynr(int(t.year), 1, 1)
  	mondayFirst := wb.test(weekBehaviourMondayFirst)
  	weekYear := wb.test(weekBehaviourYear)
  	firstWeekday := wb.test(weekBehaviourFirstWeekday)
  
  	weekday := calcWeekday(firstDaynr, !mondayFirst)
  
  	year = int(t.year)
  
  	if t.month == 1 && int(t.day) <= 7-weekday {
  		if !weekYear &&
  			((firstWeekday && weekday != 0) || (!firstWeekday && weekday >= 4)) {
  			week = 0
  			return
  		}
  		weekYear = true
  		year--
  		days = calcDaysInYear(year)
  		firstDaynr -= days
  		weekday = (weekday + 53*7 - days) % 7
  	}
  
  	if (firstWeekday && weekday != 0) ||
  		(!firstWeekday && weekday >= 4) {
  		days = daynr - (firstDaynr + 7 - weekday)
  	} else {
  		days = daynr - (firstDaynr - weekday)
  	}
  
  	if weekYear && days >= 52*7 {
  		weekday = (weekday + calcDaysInYear(year)) % 7
  		if (!firstWeekday && weekday < 4) ||
  			(firstWeekday && weekday == 0) {
  			year++
  			week = 1
  			return
  		}
  	}
  	week = days/7 + 1
  	return
  }
docs: // calcWeek calculates week and year for the time.