mktime()
Howland Craig D (Craig)
howland@LGSInnovations.com
Wed Aug 17 20:55:00 GMT 2011
Steve:
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
comment
on this case. The patch as it is chooses to ignore the given tm_isdst
when the current timezone has no DST.
Craig
2011-08-17 Craig Howland <howland@LGSInnovations.com>
* libc/time/mktime.c: set tm_isdst=0 when !daylight; account
for
tm_mon possibly being given as negative.
-----Original Message-----
From: newlib-owner@sourceware.org [mailto:newlib-owner@sourceware.org]
On Behalf Of Steven Abner
Sent: Saturday, August 13, 2011 6:36 AM
To: newlib@sourceware.org
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
purposes?
Cheers
Steve
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mktime.patch.txt
URL: <http://sourceware.org/pipermail/newlib/attachments/20110817/121ac5eb/attachment.txt>
More information about the Newlib
mailing list