def write_task_options(self, **kw):

        """
        Write an options line for a task definition::

            writer.write_task_options(
                start_time=time(12, 34, 56),
                task_time=timedelta(hours=1, minutes=45, seconds=12),
                waypoint_distance=False,
                distance_tolerance=(0.7, 'km'),
                altitude_tolerance=300.0,
            )
            # -> Options,NoStart=12:34:56,TaskTime=01:45:12,WpDis=False,NearDis=0.7km,NearAlt=300.0m

        :param start_time: opening time of the start line as
            :class:`datetime.time` or string
        :param task_time: designated time for the task as
            :class:`datetime.timedelta` or string
        :param waypoint_distance: task distance calculation (``False``: use
            fixes, ``True``: use waypoints)
        :param distance_tolerance: distance tolerance in meters or as
            ``(distance, unit)`` tuple
        :param altitude_tolerance: altitude tolerance in meters or as
            ``(distance, unit)`` tuple
        :param min_distance: "uncompleted leg (``False``: calculate maximum
            distance from last observation zone)"
        :param random_order: if ``True``, then Random order of waypoints is
            checked
        :param max_points: maximum number of points
        :param before_points: number of mandatory waypoints at the beginning.
            ``1`` means start line only, ``2`` means start line plus first
            point in task sequence (Task line).
        :param after_points: number of mandatory waypoints at the end. ``1``
            means finish line only, ``2`` means finish line and one point
            before finish in task sequence (Task line).
        :param bonus: bonus for crossing the finish line
        """

        if not self.in_task_section:
            raise RuntimeError(
                u'Task options have to be written in task section')

        fields = ['Options']

        if 'start_time' in kw:
            fields.append(u'NoStart=' + self.format_time(kw['start_time']))

        if 'task_time' in kw:
            fields.append(u'TaskTime=' + self.format_timedelta(kw['task_time']))

        if 'waypoint_distance' in kw:
            fields.append(u'WpDis=%s' % kw['waypoint_distance'])

        if 'distance_tolerance' in kw:
            fields.append(
                u'NearDis=' + self.format_distance(kw['distance_tolerance']))

        if 'altitude_tolerance' in kw:
            fields.append(
                u'NearAlt=' + self.format_distance(kw['altitude_tolerance']))

        if 'min_distance' in kw:
            fields.append(u'MinDis=%s' % kw['min_distance'])

        if 'random_order' in kw:
            fields.append(u'RandomOrder=%s' % kw['random_order'])

        if 'max_points' in kw:
            fields.append(u'MaxPts=%d' % kw['max_points'])

        if 'before_points' in kw:
            fields.append(u'BeforePts=%d' % kw['before_points'])

        if 'after_points' in kw:
            fields.append(u'AfterPts=%d' % kw['after_points'])

        if 'bonus' in kw:
            fields.append(u'Bonus=%d' % kw['bonus'])

        self.write_fields(fields)