Categories &

Functions List

Class Definition: calendarDuration

Class: calendarDuration

Array representing durations of time using flexible-length calendar date/time units.

Each calendarDuration element stores internally the number of whole months, the number of whole days, and a duration object representing hours, minutes, and seconds. It can be used to simplify calculations on datetime arrays involving calendar units.

calendarDuration arrays can be created through their constructor by combining numeric arrays representing individual calendar duration units or through the functions caldays, calweeks, calmonths, calquarters, and calyears, which create calendar durations in terms of a single calendar duration unit. These functions are also available as methods of calendarDuration arrays to extract individual calendar duration units as numeric arrays.

See also: datetime, duration

Source Code: calendarDuration

Properties

Display format, specified as a character vector or string scalar. If specified as a string scalar, it is converted and stored internally as a character vector.

Methods

calendarDuration: calD = calendarDuration (X)
calendarDuration: calD = calendarDuration (Y, MO, D)
calendarDuration: calD = calendarDuration (Y, MO, D, H, MI, S)
calendarDuration: calD = calendarDuration (Y, MO, D, T)
calendarDuration: calD = calendarDuration (…, 'Format', FMT)

Create a new array of calendar durations.

calD = calendarDuration (X) returns an array of calendar durations from numeric matrix X, which must have either three or six columns, representing years, months, days, hours, minutes, and seconds, accordingly. All but seconds must be represented as whole duration units by integer values.

calD = calendarDuration (Y, MO, D) returns an array of calendar durations from numeric arrays Y, MO, and D, which correspond to years, months, and days, respectively. The size of calD is the common size of the numeric input arguments, which must be of the same size or scalars. A scalar input functions as a constant array of the same size as the other inputs.

calD = calendarDuration (Y, MO, D, H, MI, S) returns an array of calendar durations from numeric arrays Y, MO, D, H, MI, and S, which correspond to years, months, days, hours, minutes, and seconds, respectively. The size of calD is the common size of the numeric input arguments, which must be of the same size or scalars. A scalar input functions as a constant array of the same size as the other inputs.

calD = calendarDuration (Y, MO, D, T) returns an array of calendar durations from numeric arrays Y, MO, and D, which correspond to years, months, and days, as well as a time duration array T. The size of calD is the common size of the data input arguments, which must be of the same size or scalars. A scalar input functions as a constant array of the same size as the other inputs.

Numeric input arrays Y, MO, D, H, and MI must contain integer values corresponding to whole calendar units. S can also be contain fractions of seconds.

calD = calendarDuration (…, 'Format', FMT) specifies the format in which calD is displayed. FMT must be a character vector containing the following letters.

  • 'y' years
  • 'q' quarters of a year
  • 'm' months
  • 'w' weeks
  • 'd' days
  • 't' time duration

calD = calendarDuration () returns a scalar array of calendar durations with a value of zero days. To create an empty calendarDuration array, use calendarDuration ([], [], []).

See also: calyears, calquarters, calmonths, calweeks, caldays, calendarDuration, iscalendarduration, datetime, duration

calendarDuration: cstr = dispstrings (calD)

Get display formatted strings for each element of a calendarDuration array.

cstr = dispstrings (calD) returns a cellstr array of character vectors, cstr, which has the same size as the input calendarDuration array, calD.

calendarDuration: cstr = cellstr (calD)
calendarDuration: cstr = cellstr (calD, Format)

Convert calendarDuration array to a cell array of character vectors.

cstr = cellstr (calD) returns a cellstr array of character vectors, cstr, which has the same size as the input calendarDuration calD.

calendarDuration: cmat = char (calD)

Convert calendarDuration array to a character matrix.

cmat = char (calD) returns a character matrix with one row per element in calD.

calendarDuration: DV = datevec (calD)

Convert calendarDuration array to date vectors.

DV = datevec (calD) returns a numeric matrix with one row per element in calD.

calendarDuration: T = time (calD)

Return time portion of calendarDuration array.

T = time (calD) returns a duration array T with the time portions of the calendarDuration array calD.

calendarDuration: […] = split (calD, units)

Split calendarDuration array into numeric time units.

[…] = split (calD, units) splits the calendar duration units in calD into separate numeric arrays according to date/time units specified in units, which must be either a cell array of character vectors or a string array containing any of the following date/time units in descending order.

  1. 'years'
  2. 'quarters'
  3. 'months'
  4. 'weeks'
  5. 'days'
  6. 'time'

When a single date/time unit is specified, units may also be a character vector. When 'time' is specified in units, the corresponding returning argument is a duration array. The values of years, quarters, and months are computed independently from the values of weeks and days in calD, with larger units taking precedence when specified The same applies for duration arrays, when requested.

calendarDuration: X = caldays (calD)

Calendar duration in days.

X = caldays (calD) returns a numeric array with the number of days as represented in calD.

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

calendarDuration: X = calweeks (calD)

Calendar duration in weeks.

X = calweeks (calD) returns a numeric array with the number of weeks as represented in calD.

calweeks is also available as a function, in which case it performs the opposite conversion.

See also: calendarDuration.calyears, calendarDuration.calquarters, calendarDuration.calmonths, calendarDuration.caldays, calweeks

calendarDuration: X = calmonths (calD)

Calendar duration in months.

X = calmonths (calD) returns a numeric array with the number of months as represented in calD.

calmonths is also available as a function, in which case it performs the opposite conversion.

See also: calendarDuration.calyears, calendarDuration.calquarters, calendarDuration.calweeks, calendarDuration.caldays, calmonths

calendarDuration: X = calquarters (calD)

Calendar duration in quarters.

X = calmonths (calD) returns a numeric array with the number of quarters as represented in calD.

calmonths is also available as a function, in which case it performs the opposite conversion.

See also: calendarDuration.calyears, calendarDuration.calmonths, calendarDuration.calweeks, calendarDuration.caldays, calquarters

calendarDuration: X = calyears (calD)

Calendar duration in years.

X = calmonths (calD) returns a numeric array with the number of years as represented in calD.

calmonths is also available as a function, in which case it performs the opposite conversion.

See also: calendarDuration.calquarters, calendarDuration.calmonths, calendarDuration.calweeks, calendarDuration.caldays, calyears

calendarDuration: sz = size (calD)
calendarDuration: dim_sz = size (calD, dim)
calendarDuration: dim_sz = size (calD, d1, d2, …)
calendarDuration: [rows, columns, …, dim_n_sz] = size (…)

Size of a calendarDuration array.

sz = size (calD) returns a row vector with the size (number of elements) of each dimension for the calendar duration array calD.

dim_sz = size (calD, dim) returns the size of the corresponding dimension specified in dim. If dim is a vector, then dim_sz is a vector of the same length and with each element corresponding to a specified dimension. Multiple dimensions may also be specified as separate arguments.

With a single output argument, size returns a row vector. When called with multiple output arguments, size returns the size of dimension N in the Nth argument.

calendarDuration: out = ndims (calD)

Number of dimensions in a calendarDuration array.

out = ndims (calD) returns the number of dimensions of the calendar duration array calD.

calendarDuration: out = numel (calD)

Total number of elements in a calendarDuration array.

For compatibility reasons with Octave’s OOP interface and subsasgn behavior, calendarDuration’s numel is defined to always return 1.

calendarDuration: out = nns (calD)

Number of nonzero elements in calendarDuration array.

out = nns (calD) returns the number of nonzero elements in the calendar duration array calD.

calendarDuration: TF = iscolumn (calD)

Return true if calendarDuration array is a column vector.

calendarDuration: TF = isempty (calD)

Return true if calendarDuration array is empty.

calendarDuration: TF = isequal (calD1, calD2, …)

Return true if all calendarDuration arrays are equal.

calendarDuration: TF = isequaln (calD1, calD2, …)

Return true if all calendarDuration arrays are equal under the additional assumption that NaN == NaN.

calendarDuration: TF = isfinite (calD)

Return a logical array which is true where the elements of calendarDuration array calD are finite and false where they are not. TF and calD are of the same size.

calendarDuration: TF = isinf (calD)

Return a logical array which is true where the elements of calendarDuration array calD are infinite and false where they are not. TF and calD are of the same size.

calendarDuration: TF = ismatrix (calD)

Return true if calendarDuration array is a 2-D array.

calendarDuration: TF = ismissing (calD)

Find missing data in a calendar duration array.

Missing values in calendarDuration arrays are represented by NaN, thus TF = ismissing (calD) is equivalent to TF = isnan (calD).

Note: ismissing for calendarDuration arrays does not support a second Indicator arguments.

calendarDuration: TF = isnan (calD)

Return a logical array which is true where the elements of calD are NaN values and false where they are not. TF and calD are of the same size.

calendarDuration: TF = isrow (calD)

Return true if calendarDuration array is a row vector.

calendarDuration: TF = isscalar (calD)

Return true if calendarDuration array is a scalar.

calendarDuration: TF = isscalar (calD)

Return true if calendarDuration array is a vector.

calendarDuration.minus is not documented.
calendarDuration.uminus is not documented.
calendarDuration.plus is not documented.
calendarDuration.uplus is not documented.
calendarDuration.sort is not documented.
calendarDuration.sortrows is not documented.
calendarDuration.unique is not documented.
calendarDuration.interp1 is not documented.
calendarDuration.intersect is not documented.
calendarDuration.setdiff is not documented.
calendarDuration.setxor is not documented.
calendarDuration.union is not documented.