function days = DNumofMonth(inputdate)
%DNUMOFMONTH Calculate the number of days in the input date month.
% INPUTDATE The input date, should be a string or a datenum.
% DAYS The number of the month of INPUTDATE.
% DAYS = DNUMOFMONTH(INPUTDATE)
%
% EXAMPLE:
% D = DNumofMonth('2010-1-5')
% D =
% 31
%
% D = DNumofMonth(724222)
% D =
% 30
%
% See also datenum, datevec, datestr.
D_vec = datevec(inputdate);
Year_num = D_vec(1);
Month_num = D_vec(2);
LeapYearFlag = isLeapYear(Year_num);
if Month_num == 2
if LeapYearFlag
days = 29;
else
days = 28;
end
elseif Month_num == 1 || Month_num == 3 || Month_num == 5 || ...
Month_num == 7 || Month_num == 8 || Month_num == 10 || ...
Month_num == 12
days = 31;
else
days = 30;
end