AW: [En-Nut-Discussion] Is this a bug or a feature in mktime?

Oliver Schulz olischulz at web.de
Thu Jun 9 23:48:48 CEST 2005


Hi Dave,

This behaviour is indeed by intention. If you call mktime, then the time
stored in the parameter timeptr is first adjusted to contain a valid time
information.
That means, if you provide for example 6am on June 9th with tm_isdst flag
set to zero (which means no DST time), then the time is corrected to 7am
because the 9.6.05 is a date within daylight saving. The same for a date in
december with tm_isdst set to positive value.

And you are right, following the ANSI C definitions you can switch of this
DST correction by setting the tm_isdst member of timeptr to a negative
value, but the tm_isdst is set to the correct value according to the date in
timeptr.

Cheers,
Oliver.
 

-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] Im Auftrag von Dave
Gesendet: Donnerstag, 9. Juni 2005 13:07
An: Ethernut User Chat (English)
Betreff: Re: [En-Nut-Discussion] Is this a bug or a feature in mktime?

On Thu, 2005-06-09 at 06:51 -0400, Dave wrote:
> Hi everyone,
>    I'm not sure if this is a bug or a feature. I've been playing 
> around with the mktime function, and I noticed that if set the date to 
> a time of the year, so that it is opposite of how tm_isdst is 
> currently set, then my time will be ahead or behind by one hour.
> 
>    For example, if the tm_isdst flag is clear, and I enter todays date 
> with a time of 6:00, it will set the tm_isdst flag, and put my time at 
> 7:00. If the tm_isdst flag is set, and I set the date to December and 
> the time to 6:00, then it will clear the tm_isdst flag, and set the 
> time to 5:00.
> 
>    Is it supposed to work this way? In my eyes it is a bug, but that 
> may be the way it is supposed to work. I'm sure I can 'fix' it, but I 
> don't want to break something else if it is supposed to work this way. 
> Can someone let me know before I try to fix something that may not be 
> broken?
> 
> -Dave


I got it figured out. It is not documented 100% in the Nut/OS docs, but it
appears that it is supposed to work this way, and if I simply set the
tm_isdst flag to -1 it will automagically set the tm_isdst flag for me, and
set the time as expected.

-Dave

_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion




More information about the En-Nut-Discussion mailing list