FUNCTION REFERENCE

calendarDuration

Lengths of time in calendar years, months and days.

Lengths of time in calendar years, months and days.

Syntax

cd = calendarDuration(y,m,d)

Syntax

cd = calendarDuration(y,m,d,h,mi,s)

Calendar components are immutable shared arrays. Year, month and day inputs are integers with scalar expansion; hours, minutes and seconds supply elapsed time. Months normalize into years. Addition to a datetime clamps the day to the last valid day of the destination month, then adds calendar days and elapsed time. Calendar durations support addition, subtraction and scalar multiplication. split returns separate calendar units.

Example

cd = calendarDuration(1,2,3); datetime(2024,1,31) + calmonths(1)

Differences from MATLAB: Calendar storage is capped at 128 MiB. Only these numeric constructor forms are supported. Format options, indexed assignment, ordering comparisons and persistence are not implemented. Only unzoned and UTC datetimes exist in this engine, so there are no daylight saving transitions.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.