function d = caldays(n)
%CALDAYS Create calendar durations from numeric values in units of calendar days.
%   D = CALDAYS(N) returns an array of calendar durations with each element
%   equal to the number of calendar days in the corresponding element of N. N
%   must contain integer values. D is the same size as N.
%
%   CALDAYS creates days that account for Daylight Saving Time shifts when
%   used in calendar calculations. To create exact fixed-length (i.e. 24 hour)
%   days, use the DAYS function.
%
%   See also CALWEEKS, CALMONTHS, CALQUARTERS, CALYEARS, SECONDS, MINUTES,
%            HOURS, DAYS, YEARS, DURATION, CALENDARDURATION.

%   Copyright 2014-2020 The MathWorks, Inc.
import matlab.lang.correction.ReplaceIdentifierCorrection

if nargin < 1
    n = 1;
elseif isnumeric(n)
    % OK
elseif islogical(n)
    n = double(n);
elseif isa(n,'datetime')
    ME = MException(message('MATLAB:calendarDuration:DatetimeInputCaldays'));
    ME = addCorrection(ME,ReplaceIdentifierCorrection('caldays','day'));
    throw(ME);
elseif isa(n,'duration')
    ME = MException(message('MATLAB:calendarDuration:DurationInputCaldays'));
    ME = addCorrection(ME,ReplaceIdentifierCorrection('caldays','days'));
    throw(ME);
else
    error(message('MATLAB:calendarDuration:InvalidCalDurationData'));
end

try
    d = calendarDuration(0,0,n);
catch ME
    matlab.internal.datatypes.throwInstead(ME, ...
        "MATLAB:calendarDuration:MustBeInteger", ...
        "MATLAB:calendarDuration:NonintegerCalDaysData");
end
