def _calc_julian_from_U_or_W(year, week_of_year, day_of_week, week_starts_Mon):
 first_weekday = datetime_date(year, 1, 1).weekday()
 if (not week_starts_Mon):
  first_weekday = ((first_weekday + 1) % 7)
  day_of_week = ((day_of_week + 1) % 7)
 week_0_length = ((7 - first_weekday) % 7)
 if (week_of_year == 0):
  return ((1 + day_of_week) - first_weekday)
 else:
  days_to_week = (week_0_length + (7 * (week_of_year - 1)))
  return ((1 + days_to_week) + day_of_week)

def _calc_julian_from_U_or_W ( year , week_of_year , day_of_week , week_starts_Mon ) : first_weekday = datetime_date ( year , 1 , 1 ) . weekday ( ) if ( not week_starts_Mon ) : first_weekday = ( ( first_weekday + 1 ) % 7 ) day_of_week = ( ( day_of_week + 1 ) % 7 ) week_0_length = ( ( 7 - first_weekday ) % 7 ) if ( week_of_year == 0 ) : return ( ( 1 + day_of_week ) - first_weekday ) else : days_to_week = ( week_0_length + ( 7 * ( week_of_year - 1 ) ) ) return ( ( 1 + days_to_week ) + day_of_week )
calculate the julian day based on the year .