From Egyptian sundials to Babylonian mathematics, the way we measure time is rooted in some remarkably ancient ideas