How does the presence of an atmosphere affect the length of day and night?

I am thinking by the rising and setting of the moon and sun.
Is this right?

Thank You.