function [adjustedToa] = addDrift(pToa, pOffsetBegin, pDrift, pStartTimestep)
%ADDFLOATDRIFT Summary of this function goes here
%   Detailed explanation goes here

%% Prepare return variable
adjustedToa = pToa;

%% Parameter check
if isnan(pOffsetBegin)
    pOffsetBegin = 0;
end
if isnan(pDrift)
    pDrift = 0;
end
if pOffsetBegin == 0 && pDrift == 0
    return;
end

if nargin < 4
    pStartTimestep = 0;
end

if length(pStartTimestep) > 1
    adjustedToa = artoa.toa.atGivenTimesteps(pToa, pStartTimestep, pOffsetBegin, pDrift);
    return;
end
% 
% %% Get required data
% maxToaDate = max(pToaData.toaDate);
% minToaDate = min(pToaData.toaDate);

%% Calculate offset for every toa

adjustedToa = artoa.toa.atTimestep(pToa, pStartTimestep, pOffsetBegin, pDrift);
return;

offset = [];
for i = 1:length(adjustedToa)
    offset = [ ...
        offset; ...
        artoa.toa.atTimestep( ...
            adjustedToa.toa(i), ...
            pStartTimestep + i, ...
            pOffsetBegin, ...
            pDrift ...
        ) ...
    ];
end

% offset = ((pOffsetEnd - pOffsetBegin) / (maxToaDate - minToaDate)) ...
%     * (pToaData.toaDate - minToaDate) + pOffsetBegin;

%% Add calculated offset to toa data
adjustedToa.toa = pToa.toa + offset;


end

