The lights here at three o'clock and the rooster at five o'clock are describing a scene. It means that you study until the third watch, which implies that it is relatively late; you get up at the fifth watch, which implies that you get up early; it does not actually refer to that time. It is when the man was studying, which is not the continuation of the previous sentence. It is said separately from the previous sentence. It is when the man was studying. The tense here refers to the time of youth, not the third watch and the fifth watch.