How the brain keeps time