Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!apple!bionet!agate!ucbvax!hplabs!hpda!hpcupt1!hpisod2!decot From: decot@hpisod2.HP.COM (Dave Decot) Newsgroups: comp.lang.c Subject: Re: struct tm -> time_t converter wanted Message-ID: <2550079@hpisod2.HP.COM> Date: 21 Oct 88 02:15:20 GMT References: <442@grand.UUCP> Organization: Hewlett Packard, Cupertino Lines: 31 > 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? Probably, but if you're going to do one of these yourself, please do it in the form described by ANSI C, so you can use that when you get an ANSI compiler and libraries: #include time_t mktime(timeptr) struct tm *timeptr; The mktime function converts the broken-down time, expressed as local time, in the structure pointed to by timeptr into a calendar time value with the same encoding as that of the values returned by the [time()] function. The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to the [normal ranges of those members]. On successful completion, the values of the tm_wday and tm_yday components of the structure are set appropriately, and the other components are set to represent the specified calendar time, but with their values forced [into the normal ranges]; the final value of tm_mday is not set until tm_mon and tm_year are determined. If the calendar time cannot be represented, the function returns the value (time_t)-1. Dave Decot decot@hpda