system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why/how does the body know when to wake up after routinely waking at a certain time, even though you don’t always fall asleep at the same time every night?

When I wake up at the same time every weekday  using an alarm, I wake up at that same time on weekends, even though I fall asleep a lot later Friday evenings.
I’ve been told there was an inner clock, but how does the body measure time? (Sorry if this is unclear)
gpt
The *Circadian Rhythm* is the "internal clock" of the human body. Many stimuli affect it (Habits, mental state, physical state, genetics, environmental factors, medication, etc).

One of the main components of it is a hormone called Melatonin, produced mainly in the *pineal gland* of the brain. It is mostly influenced by light (hence, using smartphones at night might cause insomnia and other sleep-related issues). Cortisol is also important in the alertness process (Waking up).

This process is also influenced by learning, i.e. the thing we call habit. If you wake up at a certain time for a period of time, the Circadian Rhythm will adjust.