[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

strtim

 
WFDB_Time strtim(char *string)
Return:

(WFDB_Time) >0
number of sample intervals corresponding to the argument interpreted as a time interval
(WFDB_Time) <0
(negated) elapsed time in sample intervals from the beginning of the record, corresponding to the argument interpreted as a time of day
(WFDB_Time) 0
a legal return if the argument matches the base time; otherwise an error return indicating an incorrectly formatted argument

This function converts an ASCII string in standard time format to a time in units of sample intervals. Examples of standard time format:

2:14.875
2 minutes + 14.875 seconds
[13:6:0]
13:06 (1:06 PM)
[8:0:0 1]
8 AM on the day following the base date
[12:0:0 1/3/1992]
noon on 1 March 1992
143
143 seconds (2 minutes + 23 seconds)
4:02:01
4 hours + 2 minutes + 1 second
s12345
12345 sample intervals
c350.5
counter value 350.5
e
time of the end of the record (if defined)
i
time of the next sample in input signal 0
o
(the letter `o') time of the next sample in output signal 0

If the argument is bracketed (as in the second, third, and fourth examples), it is taken as a time of day, and strtim uses the base time defined by the header file or by the caller (see section setbasetime); in this case, the value returned is zero or negative (and can be converted into elapsed time from the beginning of the record by simply negating it). If the argument is not bracketed, it is taken as a time interval, and converted directly into a positive number of sample intervals. These notations match those used by timstr and mstimstr, which are (approximately) inverse functions of strtim; in fact, for MIT DB and AHA DB records (and any others with sampling frequencies below 1 KHz), strtim(mstimstr(t)) = t, for any t. The `s'-format (as in the seventh example above) is provided to allow "conversion" of time intervals already expressed in sample intervals. The similar `c'-format converts counter values (see section getcfreq) into sample intervals. The length of the record in sample intervals can be obtained using strtim("e"), which evaluates to zero if this quantity is undefined. The sample number of the next sample to be read or written can be determined using strtim("i") or strtim("o"). If the argument string is incorrectly formatted, strtim returns zero (indistinguishable from a correct input that evokes a zero output); this may be considered a feature. Several of the programs in chapter 6 illustrate the use of strtim (for example, see section Example 7: A General-Purpose FIR Filter).

The next two functions convert between Julian dates and ASCII strings. Julian dates as defined by astronomers begin at noon GMT; these begin at midnight local time.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

George B. Moody (george@mit.edu)