Daylight Savings Time Roll-overs on Windows CE


Summary: On rereading this post, I realized it's pretty complicated.  The summary here is that you have the Time Service DST logic included in your CE image, then you need to add the registry keys at the bottom of this post & to install the timesvc QFE's.  You can see if you have this by opening your ceconfig.h in your releasedirectory and seeing if you have the line "#define TIMESVC_TSVC_DST 1" included.  If you have this line you have the DST stuff, otherwise you don't.


Audience: This blog applies only to general embedded customers.  On Windows Mobile devices (all versions) Daylight Savings Time transformations are handled by a separate component.  It also assumes that you are using the CE SNTP component (timesvc.dll) (http://msdn.microsoft.com/library/en-us/wcecomm5/html/wce50oriSimpleNetworkTimeProtocolSNTPService.asp?frame=true) in CE 5.0.  I promise in CE 6.0 RTM you won't have to go through any of this.


Background: Timesvc.dll is a kind of complicated DLL in that it can have from 1-3 different SYSGEN components.  Basically you can have it be a true time server where it services network clients (this would usually be in say WinCE running in a home gateway).  It can also be an SNTP client, or it can only automatically handle daylight savings time (DST) transitions (it detects when your clock passes from DST<->standard time or vice versa and automatically resets it).  The DST part is the most interesting for this post.


You may be have the DST configuration code in your OS even if you didn't explicitly request it, because if you have SYSGEN_IABASE set (which I believe you'll get with "Internet Appliance Design Template") then the DST logic will be automatically brought in.  See my notes at start of this article on determining whether you have it or not.


Problem: When you bring in the DST transition logic, it is *not* automatically enabled.  You need a registry key that's not obvious in order to have this enabled.  Because people aren't enabling this, the universal time in addition to local time is getting stored incorrectly.  (Universal time is stored incorrectly because many (if not all?) OALs store the time in local time and to get the universal time the kernel applies the current timezone bias.)


Solution: For all this background, the fix is pretty easy.
1 - First things first, if you're using timesvc make sure that you've installed all QFE's relating to it.  There have been 2 serious bugs fixed in it via QFE's.


2 - Add the following registry to your project.reg and rebuild your image.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Clock]
"AutoDST"=dword:1


[Author: John Spaith]

Comments (7)

  1. On CE 4.2, I’ve seen code in the sample Explorer shell that also seems to handle DST, a thread that is sleeping until the DST->standard time changes and adjust the time accordingly.

    Did this change in CE 5.0? is there some conflict between timesvc.dll and explorer.exe? or are we supposed to remove the DST handling code of the shell if we include timesvc?

    Thanks,

  2. cenet says:

    Philippe — you have very good eyes.  The DST code has changed between CE 4.2 & CE 5.0.  Now if the standard shell is included, it will automatically bring in timesvc.dll and explorer.exe will no longer spin up the DST handling code.  The idea here is that everyone and their brother had DST logic, so it made sense to move it to a service that everyone can use rather than having explorer.exe have its own copy and other stuff have their own copy.  Don’t get me started on the way things were 🙁 — we have made progress in this area at least.

    If you’re super curious, check out %_WINCEROOT%publicCEBaseoakmiscwceshellfe.bat, which is the dependency determination file for shell related stuff.  You’ll see that if SYSGEN_STANDARDSHELL is set, then SYSGEN_TIMESVC_DST is also automatically set.

    John Spaith

  3. Thanks a lot for the great information.

    I think the original solution of having that in the shell made sense back then.

    We didn’t have services and the shell was a piece that had to be modified or rewritten anyway to provide a UI that fit the device screen/alphanumeric display/lLEDs/…

    As DST shows a dialog, it also had to be adapted and including it in the shell ended up in less components to modify.

    Now that we have services, it definitely makes sense to have the DST code out of the shell, especially since embedded devices are more likely to provide their custom shell than on Windows XP, and every separate DST code is a chance of getting something not working exactly the way it should.

  4. casner says:

    There is one comment here that confuses me.  You mention that it can be an SNTP client only.  This does not appear to work.  I have to include the server to get the client to build.  Unfortunately, the dependency is not set to make this happen automatically.  Either that, or the client is missing a vital piece.  Yes, I do have all of the updates installed through April (May is not available yet).

  5. cenet says:

    Bruce (aka casner) — being forced to build with the server is news to me; I’m surprised since most of the time when people pull in IABase they only bring in the client portion.

    If you want to debug this further, please spin up a thread on microsoft.public.windowsce.platbuilder (which I’m better at checking than here) and include the build.err & relevant build.log portions of what breaks when you set client only, as well as SYSGEN’s that you have and public<YourProjectName>cesysgensdkincceconfig.h.

    [John Spaith]

  6. Chandan Bettahalli says:

    Hello John,

    Can you please tell me how this works on a Windows Mobile 5.0 terminal? By default we havent enabled SNTP. We use Windows Mobile AKU 3.5 for our BSP. Since SNTP is not describled in Windows Mobile documentation for OEM’s, please throw some light on this. And, will the above fix work for WM 5.0 also? If not, how is DST and SNTP handled in Windows mobile devices.

  7. cenet says:

    Chandan – WM5 does not include SNTP and MS doesn’t have an option for adding SNTP to a WM device, though I imagine there are 3rd pary options out there.  For WM5, there’s another component that does DST that’s not the same as the one from general embedded (yes I know this is gross! and I’m trying to make their component go away and use ours across all CE devices).  

    However, I think they key off the AutoDST registry value too but I’m not sure, you may want to try a newsgroup (http://blogs.msdn.com/cenet/archive/2005/12/05/500181.aspx).  In general though I think you let the user configure whether they wan AutoDST rollover or no (through the UI) and would only override this in an application for pretty specific scenarios.

    John

Skip to main content