Refactored time range handling.