mktime() failures under PCTS testing

Paul Eggert eggert at
Wed Aug 31 21:35:17 UTC 1994

If you'll recall, the tz package `mktime' normally returns -1 when
given a time in a `spring-forward' gap, but the NIST-PCTS:151-2 test
suite, Version 1.4, (1993-12-03), claims that this is a bug.

In March I submitted a formal Defect Report about this to the
committee responsible for the C Standard, and have just received a
copy of the draft response (SC22/WG14 DR#136).  This response has been
approved by WG14 but is subject to a final review, so it is not
official yet.  The response reads as follows:

	The Standard does not specify the behavior precisely enough to
	preclude `mktime' from returning a value of `(time_t)-1' and
	leaving the `tm_isdst' member set to -1 in such situations.

In other words, assuming this response becomes official as expected,
PCTS must not insist that mktime yield a value other than -1 in such
situations.  Perhaps someone who's familiar with PCTS (which I am not)
can forward this info to PCTS's maintainers.

Here's the example program that I submitted as part of Defect Report #136.
According to the draft response, a conforming implementation in a
U.S. locale can print `mktime failed' when presented with the
following program, since the requested time is in a `spring-forward' gap.

	#include <stdio.h>
	#include <time.h>
	int main() {
		struct tm t;
		time_t r;

		/* 1994-04-03 02:30:00 */
		t.tm_year = 1994 - 1900; t.tm_mon = 3; t.tm_mday = 3;
		t.tm_hour = 2; t.tm_min = 30; t.tm_sec = 0;

		t.tm_isdst = -1; /* i.e. unknown */

		r = mktime(&t);
		if (r == -1)
			printf("mktime failed\n");
			printf("%s", ctime(&r));
		return 0;

More information about the tz mailing list