<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pre_save(self, instance, add):
 """ Updates the edtf value from the value of the display_field. If there's a valid edtf, then set the date values. """

        if not self.natural_text_field or self.attname not in instance.__dict__:
            return

        edtf = getattr(instance, self.attname)

        # Update EDTF field based on latest natural text value, if any
        natural_text = getattr(instance, self.natural_text_field)
        if natural_text:
            edtf = text_to_edtf(natural_text)
        else:
            edtf = None

        # TODO If `natural_text_field` becomes cleared the derived EDTF field
        # value should also be cleared, rather than left at original value?

        # TODO Handle case where EDTF field is set to a string directly, not
        # via `natural_text_field` (this is a slightly unexpected use-case, but
        # is a very efficient way to set EDTF values in situations like for API
        # imports so we probably want to continue to support it?)
        if edtf and not isinstance(edtf, EDTFObject):
            edtf = parse_edtf(edtf, fail_silently=True)

        setattr(instance, self.attname, edtf)
        # set or clear related date fields on the instance
        for attr in DATE_ATTRS:
            field_attr = "%s_field" % attr
            g = getattr(self, field_attr, None)
            if g:
                if edtf:
                    try:
                        target_field = instance._meta.get_field(g)
                    except FieldDoesNotExist:
                        continue
                    value = getattr(edtf, attr)()  # struct_time
                    if isinstance(target_field, models.FloatField):
                        value = struct_time_to_jd(value)
                    elif isinstance(target_field, models.DateField):
                        value = struct_time_to_date(value)
                    else:
                        raise NotImplementedError(
                            u"EDTFField does not support %s as a derived data"
                            u" field, only FloatField or DateField"
                            % type(target_field))
                    setattr(instance, g, value)
                else:
                    setattr(instance, g, None)
        return edtf