function m = calmonths(n)
%CALMONTHS Create calendar durations from numeric values in units of calendar months.
%   M = CALMONTHS(N) returns an array of calendar durations with each element
%   equal to the number of calendar months in the corresponding element of N. N
%   must contain integer values. M is the same size as N.
%
%   See also CALDAYS, CALWEEKS, 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:DatetimeInputCalmonths'));
    ME = addCorrection(ME,ReplaceIdentifierCorrection('calmonths','month'));
    throw(ME);
else
    error(message('MATLAB:calendarDuration:InvalidCalDurationData'));
end

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