mktime DST detection and time field normalisation.
Sat Oct 23 12:39:00 GMT 2010
I have a query about the behaviour of mktime. It seems that if you are
relying on both DST detection and time field normalisation you can get
incorrect timezone results. It seems that the DST detection is done
before the field normalisation. For example the following code:
struct tm tm1,tm2,tm3,tm4;
if (mktime(&tm1) != mktime(&tm2))
printf("Times tm1 and tm2 differ\n");
if (mktime(&tm3) != mktime(&tm4))
printf("Times tm3 and tm4 differ\n");
results in 'Timers tm1 and tm2 differ', whereas I would have expected
them to match. I had a quick look at the mktime code, and as expected
it was very complicated. Also had no luck searching the mailing
lists/bug databases for anything relevant, possibly due to the level
of noise on other timezone/dst questions.
Is this a known limitation of the mktime dst detection algorithm?
I am using the ubuntu lucid libc 2.11.1-0ubuntu7 (same result on
2.12.1-0ubuntu8) I can also try against git if desired.
More information about the Libc-help