X3J11


Sat Feb 25 02:52:01 UTC 2012


> I was just rereading ANSI C X3J11 and noticed that strftime and mktime
> are in there.  Since POSIX is a superset (by definition) of ANSI C,
> POSIX will have strftime and mktime, it isn't an option.

I'm hoping (against hope?) that the descriptions of strftime and mktime will be
revised (or dropped from) X3J11.  I've attached part of the letter I sent to
the committee in early February.

				--ado

> Standard, Page 152, Section 4.12.2.3
> Rationale, Page 95, Section 4.12.2.3
> 
> 	Ignoring the coding and grammar errors in the Rationale,
> 	the big problem here is that code like the Rationale's
> 
> 		when = *localtime(now);
> 		when.tm_hour += 1;
> 		deadline = mktime(when);
> 
> 		printf("Loop will finish: %s\n", asctime(when));
> 		while (difftime(time(0), deadline) > 0) whatever();
> 
> 	is *not* "a paradigm for continuing some loop for an hour."
> 	The code may continue for two hours (or not at all)
> 	if it is executed just before a daylight saving time transition.
> 
> 	Since the mktime function does not (and cannot) "replace the
> 	capability to do [arithmetic] which is lost when a programmer cannot
> 	depend on time_t being an integral multiple of some known time unit,"
> 	it should be dropped from the Standard (perhaps adding functions
> 	to convert between time_t values and (long?) elapsed seconds since
> 	the epoch--functions that will be extremely useful in converting
> 	"old" software).



More information about the tz mailing list