CLN: Move series' datetime handling to a separate function