time_tonums()

Converts a time string to its integer components

Call
#include <vv_sys.h>
int time_tonums(time_stp, secondsp, minutesp, hoursp, format_stp)

UCHAR *time_stp

Time string to be converted

int *secondsp Pointer to variable to hold number of seconds
int *minutesp Pointer to variable to hold number of minutes
int *hoursp Pointer to variable to hold number of hours
UCHAR *format_stp Pointer to format string
format_stp: Specify SYSTIMEFMT or a time format string of your own creation. A time format string is composed of the following characters:
H Represents hours. There can be from 2 to 6 Hs in the string.
M Represents minutes. There can only be 2 Ms in the string.
S Represents seconds. There can only be 2 Ss in the string.
am Indicates that a 12-hour clock should be used and "am" will be appended for times less than noon and "pm" will be appended for times after noon.
Any other characters may be used as separators between the components. The separators are optional. The maximum number of separators is 2 for the 24- hour clock and 3 for the 12-hour clock. If present, the separators will be copied into the destination time string.
Returns
1 The time string was successfully converted to its integer components.
0 The time could not be converted (invalid time).
Description

time_tonums() breaks the time string into three integer variables representing the number of seconds, minutes, and hours. The time string may contain only digits (0-9), blanks, separators, and the AM string ("am") or PM string ("pm") according to the specified format string.

To get the time components, time_tonums() breaks the time string into the three sub-strings defined by the format string. These sub-strings are converted to integer values and then assigned to the variables seconds, minutes, and hours according to the format string.

If the PM string is found in the time string, the number of hours is adjusted by adding 12.

The integer components of the time are checked to make sure they represent a valid time (for example, the minutes and seconds are checked to ensure that they are not greater than 59).

Related Functions

time_frnums(), date_tonums(), date_frnums()

Cautions

Pointers to the seconds, minutes, and hours variables are expected as arguments.

An invalid time (0 return) is not considered a fatal error. VV_ERR is not set; therefore, the VCS error reporting system does not report this condition.

The passed time must match the format string.


Home Contents Previous Next