Path: utzoo!attcan!uunet!husc6!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: struct tm -> time_t converter wanted Keywords: C library, time Message-ID: <8700@smoke.BRL.MIL> Date: 18 Oct 88 14:46:55 GMT References: <442@grand.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 16 In article <442@grand.UUCP> day@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.