The ts_last_valid() function
The ts_last_valid() function extracts the entry for a particular timepoint.
Syntax
ts_tselem
ts_last_valid(ts_tsdesc *tsdesc,
mi_datetime *tstamp,
mi_integer *STATUS,
mi_integer *off)
- tsdesc
- The descriptor for a time series returned by ts_open().
- tstamp
- The time stamp of interest.
- STATUS
- A pointer to an mi_integer value. See The ts_hide_elem() function for a description of STATUS.
- off
- If the time series is regular, off is set to the offset
of the returned element. If the time series is irregular, or if the
time series is empty, off is set to -1. This argument can be
passed as
NULL
.
Description
For regular time series, this function returns the first element with a time stamp less than or equal to tstamp. For irregular time series, it returns the latest element at or preceding the given time stamp.
Returns
The nearest element at or before
the given time stamp. If there is no such element before the time
stamp, NULL
is returned.
NULL
is
returned if: - The element at the timepoint is
NULL
and the time series is regular. - The timepoint is before the origin.
- The time series is irregular and there are no elements at or before the given time stamp.
This element must not be freed by the caller; it is valid until the next element is fetched from the descriptor.