This. It was explained quite clearly.
And yes, "every room gets reset" is basically magic, but so is teleportation, and for that matter time travel, regeneration, and "bigger on the inside".
Given that he's a time traveller, who's been spending literally thousands of personal years jumping about throughout the entire timeline of the whole of history, and whose knowledge has been repeatedly shown to be inhumanly vast, yes, he probably does - or at least every star in the galaxy.
Besides, given that he's also been repeatedly shown to be able to do impossible calculations in his head, he wouldn't even need that amount of knowledge. He only needs encyclopaedic knowledge of all the stars that are visible at some baseline point in time, as well as their trajectories relative to each other, and the life cycle of stars in general. Then he can extrapolate roughly how much time's passed by looking for stars and patterns he recognises based on rough projections forward. That would include the ones he would expect to have disappeared after a certain amount of time. And he would expect new stars to appear at certain locations at certain points, since stars don't materialise out of nothing but form out of nebulae, and he'd know where those were.
I have to say, the Doctor's ability to work out roughly how much time has passed by looking at the sky is surely the least implausible aspect of the entire episode, given who he is!