def METHOD_NAME(cursor_datetime: datetime, file_datetime: datetime) -> datetime:
    if file_datetime > cursor_datetime:
        return file_datetime
    else:
        # Extract the dates so they can be compared
        cursor_date = cursor_datetime.date()
        date_obj = file_datetime.date()
        # If same day, update the time to the cursor time
        if date_obj == cursor_date:
            return file_datetime.replace(hour=cursor_datetime.hour, minute=cursor_datetime.minute, second=cursor_datetime.second)
        # If previous, update the time to end of day
        else:
            return file_datetime.replace(hour=23, minute=59, second=59, microsecond=999999)