The celestial compass of insects uses skylight to estimate the solar azimuth. However, time-dependent changes in the solar azimuth would cause drifts to the paths of insects that aim to keep a fixed bearing for several hours or revisit their favourite food site after a break. Thus, insects developed a time compensation mechanism to correct their compass for that drift by predicting the changes in the solar azimuth. We propose a computational model of the insects’ celestial compass, including a time compensation mechanism, and justify it based on the anatomy of the insect brain. The fan-like arrangement of the dorsal rim ommatidia allows the medulla to directly decode the direction with the highest light intensity or polarisation. The difference between light intensity and polarisation accurately encodes the solar azimuth in a sinusoidal pattern of activity across a population of (MeTu2) neurons. Dorsal neurons provide time information in the AOTu, and their activity follows a sinusoidal pattern across the day-night cycle. We suggest that the sinusoids representing the solar azimuth (MeTu2) and time (DN1pB) combine in the TuBu1 neurons to implement an important trigonometric identity that corrects for the changes in the solar azimuth and result in a geocentric compass. The compass breaks close to the equator, where the changes of the solar azimuth could be either clockwise or counter-clockwise, depending on the time of the year. Thus, migrating insects that cross the equator need a more sophisticated mechanism that requires their latitude on Earth. Interestingly, the latitude is a monotonic function of the magnetic dip, which is detectable by some migrating insects like monarch butterflies. We suggest that the magnetic dip is an input to the celestial compass circuit of some migrating insects, breaking the ambiguity between the northern and southern hemispheres, and effectively transforming the celestial into a true compass.