Weird Time Problem

  • Thread starter Thread starter Richard
  • Start date Start date
R

Richard

My custom shell grabs the current time when the shell program starts up. It
then has a counter that counts the number of seconds, minutes, hours, and
days the machine has been up. It works great, 95% of the time.

Sometimes when XPe Boots, the shell loads and starts its counting. After
about 30 seconds, the cursor hour glass comes up for a second and my time
changes to an hour before the time was originally when my shell started.
This plays havoc on my shell count since the current time now is before the
start time.

I use GMT time, the only thing I can think of is that something happens
during boot where windows converts the time. 95% of the time, my shell
loads after that conversion, sometimes, it may load before that conversion.

I'm doing a simple deal like this....

On Form Create Event....
CompStartTime := Now;

Then once per second, I get the current time and do
a subtraction to find elapsed time. ElapsedTime := Now - CompStartTime;
Then I decode Elapsed time into the segments I need.

Always works except for the occassional boot problem.

Any idea what's going on and how I may get around it?

Richard
 
Hi Richard,

Don't use time for counting purposes like this.
Use functions like GetTickCount that do not depend on time changes made by user or daylight saving.

You can always calculate day:hour:min:sec:ms from above value.

Best regards,
Slobodan
 
Thanks, I'll check it out.

Richard

Slobodan Brcin (eMVP) said:
Hi Richard,

Don't use time for counting purposes like this.
Use functions like GetTickCount that do not depend on time changes made by user or daylight saving.

You can always calculate day:hour:min:sec:ms from above value.

Best regards,
Slobodan
 
Slobodan's suggestion is the best for any "relative" time counting requirement as the additional benefit of using GetTickCount is that the machine run time is still accurate even if the user changes the time or auto time sync. etc...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

FBA booting time 5
Custom Shell Replacement Boots Slowly 5
XPe OS keeps rebooting problem 3
Horm specifics 1
Inserting SSD to new kit 1
CF boot issue 0
Boot Time - Wow 7
Custom Shell and Drivers 1

Back
Top