struct tm -> time_t converter wanted

Doug Gwyn gwyn at smoke.BRL.MIL
Wed Oct 19 00:46:55 AEST 1988


In article <442 at grand.UUCP> day at grand.UUCP (Dave Yost) writes:
>I was surprised to find no routine in the C library
>to convert a struct tm into a time_t.  Is there
>such a routine floating around somewhere?

Hi, Dave!

The proposed ANSI C Standard specifies
	time_t mktime(struct tm *timeptr);
for this purpose.  This is essentially an invention, as X3J11
also was unable to identify such a routine in wide use.  It
will not be widely available just yet, but if someone is going
to write one, they should follow this form.  The most important
thing to know that isn't evident is that the struct tm need not
be "normalized"; mktime does the appropriate range reduction.
If the time cannot be represented, (time_t)-1 is returned.



More information about the Comp.lang.c mailing list