TIMEC(3) TIMEC(3) NAME timec, timegm, timelocal - convert ASCII to time SYNOPSIS #include <time.h> long timec(string) char *string; long timegm(timep) struct tm *timep; long timelocal(timep, zone) struct tm *timep; char *zone; DESCRIPTION These routines are inverse to ctime(3) and its relatives. See ctime(3) for data layouts. Timec converts to system format a date string as produced by ctime, date(1), or ls(1). An optional day of the week is ignored. A month name and day are required. A missing hour:min[:sec] field is taken to be 00:00:00. An optional time zone (local time by default) may appear before or after the year. A missing year is assumed to be the past 12-month interval. Timegm returns the system-format time corresponding to the broken-down GMT time pointed to by timep. In a copy of the broken-down time tm_mon is reduced mod 12 by carrying (posi- tively or negatively) to tm_year. Next tm_mon and tm_mday are added to tm_yday appropriately for tm_year. Then tm_sec, tm_min, tm_hour, tm_yday, and tm_year are adjusted by carrying. Finally the system-format date is calculated from these 5 fields. Timelocal is like timegm, except that the broken-down time belongs to the specified time zone, or is local time if zone is zero. Time zones and months are recognized by the first three characters, regardless of case. Strings for ctime may con- tain names longer than three characters and may contain extra white space and commas. EXAMPLES Set a date ahead one month: struct tm brk_out = *localtime(&date); brk_out.tm_yday = 0; TIMEC(3) TIMEC(3) brk_out.tm_mon++; date = timelocal(&brk_out,0); Convert a date(1) string to system format: date = timec("Sat Sep 27 20:59:11 EDT 1986"); SEE ALSO ctime(3), time(2) BUGS Unknown time zone names are taken to be GMT. Times before the epoch yield nonsense.