The Roman’s determined the changes in the month by the moons phases (there were only 3 at the time). Therefore, they determined the changes in the month based on how the moon came out.
Every gerund has the same form - verb + -ing. So, having that in mind, the word <em>sleeping </em>is used as a gerund in this sentence, but it is also a subject of the sentence.