Converting Times From and To Their Integer Components

Times can be stored as separate integers for the hours, minutes, and seconds. To convert a time string to its integer components, use the time to numbers function, time_tonums():

int time_tonums(time_stp, secondp, minutep, hourp, format_stp)
 
UCHAR *time_stp;
/* Time string to convert
*/
int *secondp;
/* Pointer to variable to place seconds
*/
int *minutep;
/* Pointer to variable to place minute
*/
int *hourp;
/* Pointer to variable to place hours
*/
UCHAR *format_stp;
/* Time format string to use
*/

The time string is broken into the three sub-strings defined by the format string. Each of these is converted to an integer value and checked that it is the valid range for that component. The integers are copied to the variables pointed to in the call. time_tonums() expects pointers to these variables in the call.

To convert the integer components of a time into a time string, call the time from numbers function, time_frnums():

int time_frnums(time_stp, seconds, minutes, hours, format_stp)
 
UCHAR *time_stp;
/* Time string to hold formatted time
*/
int seconds;    
/* Number of seconds
*/
int minutes;
/* Number of minutes
*/
int hours;
/* Hours
*/
UCHAR *format_stp;
/* Time format string to use
*/


Home Contents Previous Next