code: def gregorian_to_julian(day):
      
      before_march = 1 if day.month < MARCH else 0
  
      #
      # Number of months since March
      #
      month_index = day.month + MONTHS_PER_YEAR * before_march - MARCH
  
      #
      # Number of years (year starts on March) since 4800 BC
      #
      years_elapsed = day.year - JULIAN_START_YEAR - before_march
  
      total_days_in_previous_months = (153 * month_index + 2) // 5
      total_days_in_previous_years = 365 * years_elapsed
      total_leap_days = (
          (years_elapsed // 4) -
          (years_elapsed // 100) +
          (years_elapsed // 400)
      )
  
      return sum([
          day.day,
          total_days_in_previous_months,
          total_days_in_previous_years,
          total_leap_days,
          -32045,      # Offset to get January 1, 4713 equal to 0
      ])
docs: Convert a datetime.date object to its corresponding Julian day.
  
      :param day: The datetime.date to convert to a Julian day
      :returns: A Julian day, as an integer