def _fit(nums, date_format):
    """
    Pass date as an array of form [day,month,year]
    if position is set the number must go there
    """
    n = 0
    for num in nums:
        n += 1 if num != None else 0
    date = [None, None, None]
    if n == 3:
        form = date_format
        if date_format[0] != None:
            if date_format[0] == 'D':
                form = ['D', 'M', 'Y']
            elif date_format[0] == 'M':
                form = ['M', 'D', 'Y']
            elif date_format[0] == 'Y':
                form = ['Y', 'M', 'D']
        elif date_format[1] != None:
            if date_format[1] == 'M':
                if date_format[2] == 'Y':
                    form = ['D', 'M', 'Y']
                elif date_format[2] == 'D':
                    form = ['Y', 'M', 'D']
            elif date_format[1] == 'D':
                form = ['M', 'D', 'Y']
        elif date_format[2] != None:
            if date_format[2] == 'D':
                form = ['Y', 'M', 'D']
        for i, item in enumerate(form):
            if item == 'D':
                date[0] = nums[i]
            elif item == 'M':
                date[1] = nums[i]
            elif item == 'Y':
                date[2] = nums[i]
        if form[1] == 'M':
            if nums[0] <= 31:
                date[0] = nums[0]
                date[2] = nums[2]
            elif nums[2] <= 31:
                date[0] = nums[2]
                date[2] = nums[0]
        elif form[2] == 'Y':
            if nums[1] > 12:
                date[0] = nums[1]
                date[1] = nums[0]
            elif nums[0] <= 31:
                date[0] = nums[0]
                date[1] = nums[1]
        if form[0] == form[1] == form[2] == None:
            if nums[1] > 12:
                date[0] = nums[1]
                date[1] = nums[0]
                date[2] = nums[2]
            elif nums[0] <= 31:
                date[0] = nums[0]
                date[1] = nums[1]
                date[2] = nums[2]
            else:
                date[0] = nums[2]
                date[1] = nums[1]
                date[2] = nums[0]
    elif n == 2:
        form = date_format
        if date_format[0] == 'D' or date_format[1] == 'M':
            form = ['D', 'M', None]
        elif date_format[0] == 'M' or date_format[1] == 'D':
            form = ['M', 'D', None]
        for i, item in enumerate(form):
            if item == 'D':
                date[0] = nums[i]
            elif item == 'M':
                date[1] = nums[i]
        if form[0] == form[1] == None:
            if nums[1] > 12:
                date[0] = nums[1]
                date[1] = nums[0]
            elif 31 >= nums[0]:
                date[0] = nums[0]
                date[1] = nums[1]
    if date[2] != None and date[2] < 1000:
        date[2] += 2000
    return ['date', date]
