How to calculate air temperature for given time, location and altitude?
The answer that you seek does not exist. There is no easy formula that might be useful. Deriving a temperature based on solar radiation is also unrealistic since the system has very large latencies and complex interactions so that you'd end up writing a full-blown weather model. This appears to be beyond the scope of your intentions.

The question you need to ask is which effects are relevant to you and how accurate you want your model to be. Also, which quantities do you require? The answers affect your course of action. Since you mention flying aircraft, you may likely want vertical profiles of atmospheric temperature above a given location. Also, which of the following effects do you need to include:


Day/Night variation
Clouds, rain
Temperature inversions
Effect of different terrains (ocean vs land for example)
Large variations in geographical location
possibly other things


A good starting point are standard atmospheres (c.f. https://en.wikipedia.org/wiki/International_Standard_Atmosphere). Another approach would be to find real-world locations that are sufficiently similar to the locations you are interested in and provide measurements. These might be adapted to your situation. 

A simple approach might be to tabulate a base temperature and height for different climatic zones and seasons and then apply the atmospheric lapse rate (-6.5K per km height) to these values. 

On a final note, I don't know what you need this information for. But be aware that for many thermodynamic purposes, the errors that you make are not going to be that large anyway since even an error of 20-30K is only an error of around 10% in absolute temperature. So be sure to evaluate your precision requirements.