August 13 C Standard Rationale on mktime

Arthur David Olson ado
Tue Sep 1 23:26:37 UTC 1987


> . . .the sole purpose of mktime is for doing arithmetic on time_t's. . .
> if the caller has to set tm_isdst before calling mktime().
> The use that most people want for mktime() is to be able to parse
> a string (or whatever) into the tm_hour fields, etc, and then produce
> a time_t .. having to second guess whether dst applied at that particular
> time is never going to work. . .

Well, much of the time it will work if you're prepared to check the values
that mktime drops into the "struct tm" passed to it, and if you've saved away
the values you passed in.  You guess one way or the other on tm_isdst and
call mktime.  If mktime changes tm_hour on you, you guess "the other" way
and try again.  Second guessing, yes; third guessing, no.

Of course the Standard is mum about the need to do this, and about the need
to handle other problems mentioned by kre.

				--ado



More information about the tz mailing list