anchor.diff:  timestamp() ->
       {TM, TS, _} = os:timestamp(),
       (TM * 1000000) + TS.
  +
  +%% @doc This function takes a list of records and an authority records. Removes old authority in the
  +%% record list and adds the new authority. Returns the new record list
  +%% @end
  +-spec remove_old_soa_add_new([dns:rr()], dns:rr()) -> [dns:rr()].
  +remove_old_soa_add_new(Records, NewAuthority) ->
  +    remove_old_soa_add_new(NewAuthority, Records,  []).
  +
  +remove_old_soa_add_new(_NewAuthority, [],  NewRecords) ->
  +    NewRecords;
  +remove_old_soa_add_new(NewAuthority, [Record | Records], NewRecords) ->
  +    case Record#dns_rr.data of
  +        #dns_rrdata_soa{} ->
  +            remove_old_soa_add_new(NewAuthority, Records, [NewAuthority | NewRecords]);
  +        _ ->
  +            remove_old_soa_add_new(NewAuthority, Records, [Record | NewRecords])
  +    end.
positive.code:     NotifySourceIP, Version, Records) ->
    RecordsByName = build_named_index(Records),
    Authority = lists:filter(erldns_records:match_type(?DNS_TYPE_SOA), Records),
  %%   Authorities = lists:foldl(fun(A, Acc) ->
  %%                     SOA = A#dns_rr.data,
  %%                     [{timestamp() + SOA#dns_rrdata_soa.expire, A} | Acc]
  %%                         end, [], Authorities0),
    #zone{name = Qname, allow_notify = AllowNotifyList, allow_transfer = AllowTransferList,
        allow_update = AllowUpdateList, also_notify = AlsoNotifyList, notify_source = NotifySourceIP,
        version = Version, record_count = length(Records), authority = Authority, records = Records, records_by_name = RecordsByName}.
  
negative.code:     SOA = SOA0#dns_rrdata_soa{serial = Serial + 1},
      Zone = build_zone(ZoneName, Zone0#zone.allow_notify, Zone0#zone.allow_transfer,
          Zone0#zone.allow_update, Zone0#zone.also_notify, Zone0#zone.notify_source, Zone0#zone.version,
          [Authority#dns_rr{data = SOA}],  remove_old_soa_add_new(Records, Authority#dns_rr{data = SOA})),
      %% Put zone back into cache. And send notify if needed.
      ok = delete_zone(ZoneName),
      case SendNotify of
          false ->
              ok = put_zone(ZoneName, Zone);
          true ->
              ok = put_zone(ZoneName, Zone),
              send_notify(ZoneName, Zone)
      end.
  
  