function d = between(t1,t2,components)
%BETWEEN Difference between datetimes as calendar durations.
%   
%   D = BETWEEN(T1,T2)
%   D = BETWEEN(T1,T2,COMPONENTS)
%   
%   See also BETWEEN.
%   


%   Copyright 2016-2020 The MathWorks, Inc.

narginchk(2,3);

% Char inputs cause problems, so convert them to strings. This ensures that
% the resulting computation is elementwise.
if ischar(t1)
    t1 = string(t1);
end
if ischar(t2)
    t2 = string(t2);
end

% The COMPONENTS parameter should be a string and should always be gathered.
% T1 and T2 are both "data" so we use a binary element-wise op.
if (nargin==2)
    fcn = @between;
else
    components = distributedutil.CodistParser.gatherIfCodistributed(components);
    fcn = @(a,b) between(a, b, components);
end
 
d = codistributed.pElementwiseOp(fcn, t1, t2);

