Ancient astronomy, religion, and empires all shaped the seven-day week—and the odd logic still guides modern calendars.