def noon_and_midnight(
        self,
        dt: datetime.datetime,
        sunset: datetime.datetime | None = None,
        sunrise: datetime.datetime | None = None,
    ) -> tuple[datetime.datetime, datetime.datetime]:
        """Return the (adjusted) noon and midnight times for the given datetime."""
        if (
            self.sunrise_time is None
            and self.sunset_time is None
            and self.min_sunrise_time is None
            and self.max_sunrise_time is None
            and self.min_sunset_time is None
            and self.max_sunset_time is None
        ):
            solar_noon = self.astral_location.noon(dt, local=False)
            solar_midnight = self.astral_location.midnight(dt, local=False)
            return solar_noon, solar_midnight

        if sunset is None:
            sunset = self.sunset(dt)
        if sunrise is None:
            sunrise = self.sunrise(dt)

        middle = abs(sunset - sunrise) / 2
        if sunset > sunrise:
            noon = sunrise + middle
            midnight = noon + timedelta(hours=12) * (1 if noon.hour < 12 else -1)
        else:
            midnight = sunset + middle
            noon = midnight + timedelta(hours=12) * (1 if midnight.hour < 12 else -1)
        return noon, midnight
Return the (adjusted) noon and midnight times for the given datetime.
webapp/color_and_brightness.py