i get the time via own sntp client (with timezone adjust) - works fine
but what about Daylight Saving Time ?
i found API SetDaylightTime() and the registry keys (AutoDST, HomeDST)
the two registry keys are not present on my system per dafault (i have
created it)
what i want is an automatic DST-adjust (after a manual sntp-request)
- which value i should set for the reg-keys ?
- what about SetDaylightTime() ?
So, you should do NOTHING, except set the correct time zone and DST status
on your device (and set the Automatically Adjust for Daylight Time option).
The rest is entirely automatic based on those foundations.
Paul T.
> So, you should do NOTHING, except set the correct time zone and DST status
> on your device (and set the Automatically Adjust for Daylight Time option).
so i set AutoDST=1, HomeDST=1
and for STD : SetDaylightTime(0), DST : SetDaylightTime(1)
?
As for SetDaylightTime(), if you know, somehow, whether you are currently on
daylight time or not, yes, you can do that. The Date/Time Control Panel
applet and the DST service both check the current date and time and figure
out the correct state of the DST flag. The DST service does this on startup
of the service and the Control Panel applet does it any time you change the
time from there.
I guess I'd need to know when and why you're thinking about calling
SetDaylightTime() to know if what you plan to do makes sense. I never call
that on my devices, unless specifically commanded to do so by the user; I
assume he knows what he's doing. If you're talking about initial set up of
the device, it seems like you could just instruct the user to set the date,
time, and time zone the first time he boots the device.
Paul T.
AutoDST = 0
HomeDST = 0
SetDaylightTime(0)
timezone : berlin,rome,...
>>> REBOOT
actual time : 22.04.2010 09:01
>>> SNTP REQUEST
get sntp time : 22.04.2010 07:01
after timezone correction : 22.04.2010 08:01
actual time : 22.04.2010 08:01
SetDaylightTime(1)
actual time : 22.04.2010 08:01
SetDaylightTime(0)
actual time : 22.04.2010 09:01
so
SetDaylightTime(1) = STD-Time ?
SetDaylightTime(0) = DST-Time ?
msdn says about SetDaylightTime():
A value of 1 indicates that daylight saving time is in effect.
A value of zero indicates that standard time is in effect.
If you reboot, the DST flag is stored in the registry (which of course, we
can't tell if you are properly persisting!), and loaded during startup to set
the initial state of the DST flag.
I think you're trying too hard to make the DST flag into something that is
generally known by the device. It generally works. Again, set the time in
the Control Panel Date/Time applet and verify that you set the time zone
first. Once you've done that, the DST flag has been set by the Control Panel
and you don't have to change it. If you do change it, then setting the time
will give the wrong result.
Paul T.
registry is persisting on sd card (reg hive)
i set the time through snyc with a sntp time server (timezone is set before
request) - works
only the daylight saving doesnt work correct
whe you speak of the DST flag - which flag you mean ?
1. Time zone. Call SetTimeZoneInformation().
2. Date/time. SetLocalTime(). Now you have a problem. You can use the
code, like what the time service uses, to decide if it should be DST or not.
Call SetDaylightTime().
3. After SetDaylightTime(), you may have changed the time, effectively.
That is, if the system had the DST flag set before your call to
SetDaylightTime() and you unset it (or the reverse), the system will change
the time for you. You have to go back and set the time again to force it to
be what the user told you it was. The alternative is to ask the user if DST
should be set or not and call SetDaylightTime() before SetLocalTime().
4. Allow your time service operations to run.
The DST flag is a flag set by the system in response to SetDaylightTime()
and changed automatically, if you have that enabled in your OS build, at the
correct date/time based on the selected time zone. It's actually stored in
the kernel and recalculated each time the device reboots. Look up
SC_SetDaylightTime() in the PRIVATE code and you'll see how it works...
Paul T.
- how do i enable this in the os build ?
- maybe my problem is, that i use only SetSystemTime (sets also the rtc
time) instead of SetLocalTime ?