Howland Craig D (Craig)
Wed Aug 17 20:55:00 GMT 2011

     I agree that the month test should include a <0 check to be
consistent with the other tests.
     tm_isdst should indeed be set to 0 when there is no DST and it is
passed as -1.  (The code produces the correct time result in this case,
failing only to change tm_isdst appropriately.)
     I have attached a patch which addresses both of these problems.
     This also raises an interesting question about what to do with no
DST (e.g. with GMT) but the user passes tm_isdst>=1.  It could be
considered to be illegal input.  Neither the C standard nor POSIX
on this case.  The patch as it is chooses to ignore the given tm_isdst
when the current timezone has no DST.
2011-08-17  Craig Howland <>

	* libc/time/mktime.c:  set tm_isdst=0 when !daylight; account
	tm_mon possibly being given as negative.

-----Original Message-----
From: []
On Behalf Of Steven Abner
Sent: Saturday, August 13, 2011 6:36 AM
Subject: mktime()

Good day,
  Running some tests and found an omission?
In the mktime.c file, the function "validate_structure", it appears (to
me) that the month test
might be incomplete?
 "if (tim_p->tm_mon > 11)"
should it possibly be:
"if (tim_p->tm_mon > 11 || tim_p->tm_mon < 0)"

And this probably should be second thread?? but I tried using the
environment variable
"TZ=GMT0" and I get tm_isdst = -1 when passing -1 in. Not sure, in this
case, if user
should be setting to 0?.  It could also be that I screwed up on porting
newlib code for testing


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mktime.patch.txt
URL: <>

More information about the Newlib mailing list