Well I did something different, but it works
I calculate the distance to the horizon based on altitude.
Using this I calculate one of the intersection points between a circle at the aircraft location with a radius of the above distance and a circle at 0,0,0 with the same radius as the Earth.
I convert this into a direction and compare it with the sun light direction.
Complicated, but it woks