Categories &

Functions List

Class Definition: datetime

Class: datetime

Array representing points in time using the Gregorian calendar.

The underlying implementation relies on the 'date.h' C++ library and stores internally the datetime points are double arrays representing whole years, months, days, hours, and minutes, as well as seconds including their fractional part. The precision of this implementation is set at microseconds, which is substantial for typical times.

A datetime array is a collection of date/time elements, with each element holding a complete date/time. The datetime array also has TimeZone and Format properties associated with it, which apply to all elements in the array.

See also: calendarDuration, duration

Source Code: datetime

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.

A read-only property specifying the local time zone of the system, where Octave is running.

TimeZone, 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

datetime: Τ = datetime ('now')
datetime: Τ = datetime ('today')
datetime: Τ = datetime ('tomorrow')
datetime: Τ = datetime ('yesterday')
datetime: Τ = datetime (DateStrings)
datetime: Τ = datetime (DateStrings, 'InputFormat', INFMT)
datetime: Τ = datetime (DateStrings,

'InputFormat', INFMT, 'PivotYear', PIVOT)

<
/dd>
datetime: Τ = datetime (DateVectors)
datetime: Τ = datetime (Y, MO, D)
datetime: Τ = datetime (Y, MO, D, H, MI, S)
datetime: Τ = datetime (Y, MO, D, H, MI, S, MS)
datetime: Τ = datetime (X, 'ConvertFrom', TYPE)
datetime: Τ = datetime (…, 'Format', FMT)
datetime: Τ = datetime (…, 'TimeZone', TZ)

Create a new array of datetime values.

Τ = datetime ('now') returns a scalar datetime array corresponding to the current date and time. Τ = datetime ('now') is the same as Τ = datetime (). Except for 'now', the same syntax can be used with 'today', 'tomorrow' and 'yesterday'. These options return the respective date but with time set at midnight.

Τ = datetime (DateStrings) creates a datetime array from the text in DateStrings representing points in time. In current implementation, DateStrings are parsed by Octave’s core datevec function, hence supported text formats are currently those supported by datevec.

Τ = datetime (DateStrings, 'InputFormat', INFMT) also allows to specify a particular input text format to parse DateStrings. It is always preferable to specify the format INFMT if it is known. Formats which do not specify a particular time component will have the value set to zero. Formats which do not a date will default to January 1st of the current year.

Τ = datetime (DateStrings, 'InputFormat', INFMT, 'PivotYear', PIVOT) also allows to specify a pivot year, which refers to the year at the start of the century to which two-digit years will be referenced. When not specified, it defaults to the current years minus 50.

Τ = datetime (DateVectors) creates a column vector of datetime values from the date vectors in DateVectors.

Τ = datetime (Y, MO, D creates an array of datetime values for corresponding elements of the Y, MO, and D arrays, which must be of the same size or scalars, must contain integer values, and they correspond to years, months, and days, respectively.

Τ = datetime (Y, MO, D, H, MI, S) also adds time components to the constructed datetime arrays. H, MI, and S must be of the same size or scalars. H and MI must contain integer values, whereas S may also contain a fractional part.

Τ = datetime (Y, MO, D, H, MI, S, MS) also adds a milliseconds component, MS, which may also have a fractional part.

Τ = datetime (X, 'ConvertFrom', TYPE) converts the numeric values in X to a datetime array accordinng to the data type specified by TYPE. The following types are suppoerted:

  • 'datenum'
  • 'excel'
  • 'posixtime'
  • 'epochtime'

Τ = datetime (…, 'Format', FMT) specifies the display format of the values in the output datetime array. Currently, only the default display format is implemented.

Τ = datetime (…, 'TimeZone', TZ) sets the time zone to the values in the output datetime array. If not specified, the computer’s local timezone is used. Supported time zones are specified in the IANA’s Time Zone Database. You may specify a new time zone by setting the 'TimeZone' property of the datetime array, in which case the new datetime values may include Daylight Saving Time (DST) in their computation.

See also: NaT, datetime, isdatetime, calendarDuration, duration

datetime: cstr = dispstrings (Τ)

Get display formatted strings for each element of a datetime object.

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

datetime: cstr = cellstr (T)
datetime: cstr = cellstr (T, Format)

Convert datetime array to a cell array of character vectors.

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

datetime: cmat = char (T)
datetime: cmat = char (T, Format)

Convert datetime array to a character matrix.

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

datetime: [Y, M, D] = ymd (T)

Year, Month, and Day components of datetime array.

[Y, M, D] = ymd (T) returns the year, month, and day components of the corresponding datetime values in T as separate numeric arrays. Y, M, D contain integer values and have the same size as T.

Method: [h, m, s] = hms (T)

Hour, Minute, and Second components of a datetime array.

[h, m, s] = ymd (T) returns the hour, miute, and second components of the corresponding datetime values in T as separate numeric arrays. h and m contain integer values and s may also contain a fractional part. All outputs have the same size as T.

datetime.year is not documented.
datetime.quarter is not documented.
datetime.month is not documented.
datetime.week is not documented.
datetime.day is not documented.
datetime.hour is not documented.
datetime.minute is not documented.
datetime.second is not documented.
datetime.timeofday is not documented.
datetime.tzoffset is not documented.
datetime: sz = size (T)
datetime: dim_sz = size (T, dim)
datetime: dim_sz = size (T, d1, d2, …)
datetime: [rows, columns, …, dim_n_sz] = size (…)

Size of a datetime array.

sz = size (T) returns a row vector with the size (number of elements) of each dimension for the datetime array T.

dim_sz = size (T, 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.

datetime: out = ndims (T)

Number of dimensions in a datetime array.

out = ndims (T) returns the number of dimensions of the datetime array T.

datetime: out = numel (T)

Total number of elements in a datetime array.

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

datetime.histcounts is not documented.
datetime.min is not documented.
datetime.max is not documented.
datetime.mink is not documented.
datetime.maxk is not documented.
datetime.plot is not documented.
datetime.convertTo is not documented.
datetime.exceltime is not documented.
datetime.posixtime is not documented.
datetime.juliandate is not documented.
datetime.yyyymmdd is not documented.
datetime: DV = datevec (T)

Convert datetime array to date vectors.

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

datetime.isbetween is not documented.
datetime.iscolumn is not documented.
datetime.isdst is not documented.
datetime.isempty is not documented.
datetime.isequal is not documented.
datetime.isequaln is not documented.
datetime.isfinite is not documented.
datetime.isinf is not documented.
datetime.ismatrix is not documented.
datetime.ismember is not documented.
datetime.isnat is not documented.
datetime.isregular is not documented.
datetime.isrow is not documented.
datetime.isscalar is not documented.
datetime.issorted is not documented.
datetime.issortedrows is not documented.
datetime.isvector is not documented.
datetime.isweekend is not documented.
datetime.sort is not documented.
datetime.sortrows is not documented.
datetime.unique is not documented.
datetime.interp1 is not documented.
datetime.intersect is not documented.
datetime.setdiff is not documented.
datetime.setxor is not documented.
datetime.union is not documented.