calendarDuration.caldays
calendarDuration: X = caldays (calD)
Calendar duration in days.
X = caldays (calD) returns a numeric array with the
number of days as represented in calD.
A month has no fixed number of days, so an array carrying any month at
all cannot be stated in days and is an error rather than a guess. Use
split on such an array, which reports each unit separately. The
sign plays no part: a negative number of months is refused exactly as a
positive one is.
A NaN or infinite month count is not refused. It is not known to
be non-zero, so it propagates as NaN or Inf, just as
calmonths, calquarters and calyears already report
it. MATLAB instead refuses such a span when it was built by the
constructor, while accepting the very same span built by caldays;
two spellings of one value cannot sensibly disagree, so both are
accepted here.
caldays is also available as a function, in which case it performs
the opposite conversion.
See also: calendarDuration.calyears, calendarDuration.calquarters, calendarDuration.calmonths, calendarDuration.calweeks, caldays
Source Code: calendarDuration
As a calendarDuration method, caldays returns the day part of the span as a whole number of days.
d = calendarDuration (0, 0, 40)
d = calendarDuration 40d
caldays (d)
ans = 40
A month has no fixed number of days, so a span carrying any month at all cannot be stated in days and caldays refuses rather than guess. Ask split instead, which reports each unit on its own.
d = calendarDuration (2, 3, 40)
d = calendarDuration 2y 3mo 40d
[mo, days] = split (d, {'months', 'days'});
[mo, days]
ans = 27 40