function tf = isbetween(a, upper, lower, varargin)
%ISBETWEEN Determine if codistributed datetime or duration arrays are contained in an interval.
%   
%   TF = ISBETWEEN(A,LOWER,UPPER)
%   TF = ISBETWEEN(A,LOWER,UPPER,INTERVALTYPE)
%   
%   See also DATETIME/ISBETWEEN, DURATION/ISBETWEEN, CODISTRIBUTED.
%   


%   Copyright 2016-2021 The MathWorks, Inc.

narginchk(3,4)

% Guard against string inputs
if isScalarString(upper) && isUnderlyingType(a, "datetime")
    upper = datetime(upper);
end
if isScalarString(lower) && isUnderlyingType(a, "datetime")
    lower = datetime(lower);
end

varargin = distributedutil.CodistParser.gatherElements(varargin);
tf = codistributed.pElementwiseOp(@(x, up, low) isbetween(x, up, low, varargin{:}), a, upper, lower);
