<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def _should_rotate_log(self, handler):
        ''' Determine if a log file rotation is necessary '''
        if handler['rotate_log']:
            rotate_time_index = handler.get('rotate_log_index', 'day')
            try:
                rotate_time_index = self._decode_time_rotation_index(rotate_time_index)
            except ValueError:
                rotate_time_index = 2

            rotate_time_delta = handler.get('rotate_log_delta', 1)

            cur_t = time.gmtime()
            first_different_index = 9
            for i in range(9):
                if cur_t[i] != handler['log_rot_time'][i]:
                    first_different_index = i
                    break

            if first_different_index < rotate_time_index:
                # If the time deltas differ by a time step greater than what we
                # have set for the rotation (I.e., months instead of days) we will
                # automatically rotate.
                return True
            else:
                time_delta = cur_t[rotate_time_index] - handler['log_rot_time'][rotate_time_index]
                return time_delta >= rotate_time_delta

        return False