atotime - convert ASCII to time value


#include <cbase/dtypes.h>

TIME atotime (sptr)

char *sptr;


Atotime converts a string pointed to by sptr to a TIME value that is the number of seconds from midnight. Midnight has a value of 1. This format allows comparison of two time values and time arithmetic.

Atotime first tries to convert sptr with the format returned by getftime(C-3). If this fails, atotime applies a set of standard input rules. These rules allow leading blanks or tabs and then a time value of the form hh[:]mm[:]ss[cycle]. The [:] character can be any punctuation character or none at all. Minutes, mm, are required only if seconds, ss, are entered. In addition, the time cycle, [cycle], can also be entered. If entered, cycle is compared against the values returned by getfcycle(C-3) case insensitive . The hours range from 1am to 12am and 1pm to 12pm. Noon is 12pm, and midnight is 12am. If the time cycle is not entered, the string sptr is assumed to be in 24 hour time, i.e., the hours go from 0 to 23.


fcountry(C-3), getftime(C-3), getfcycle(C-3), fatotime(C-3)

C/Base Reference Manual Chapter 13, "Formatting Data Values"


If the input string does not contain a valid time formats or if the string contains an invalid time (such as 02:78:00), a zero value is returned which is always an invalid TIME value. Atotime returns a zero value when the seconds, minutes or hours are invalid.


When seconds or minutes are not entered in the standard input rules, they are assumed to be zero (and valid).