Re: What time is it? Issues with Local time, system time, DST

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Apr 15, 11:14 am, trentp...@xxxxxxxxxxxxx wrote:
On Apr 15, 3:28 pm, Andrew Schweitzer <anschweit...@xxxxxxxxx> wrote:

Hi,

We are having difficulty figuring out what time it is when our board
restarts. Does someone have some wisdom about figuring out actual
system time following a reboot?

Is this in an application? You can call GetSystemTime( ) to return UTC
(i.e. system) time


Yes, this is an application, but our registry isn't directly
persisted, and we don't seemed to have "manually" restored the DST
flag yet (I'm not sure we even persist it) at the point I'm trying to
get them time. So GetSystemTime can be off by an hour in some cases.

Apparently CE (at least CE 5.0) stores time in local time, not system
time. Apparently (based on suggestions I found in newsgroups) this was
done for speed, on the assumption that most requests to get time would
be for local time, not UTC.

Maybe it does, I don't know the details. But calling GetSystemTime( )
returns system time and GetLocalTime( ) will return the local time and
accounts for any DST variations that you might have applied.


Printing the parameter to OEMSetRealTime shoes a local time. Searching
in PRIVATE dir for OEMGetRealTime and OEMSetRealTime, and looking at
how they are called seems to show that they use a local time.

So OEMSetRealTime receives, and OEMGetRealTime is expected to return,
a local time. I think (yes?) a further assumption is that the result
of an OEMSetRealTime call is that a 32 or 64 bit value representing

oops... should say "result of an OEMGetRealTime" (and that's a
SYSTEMTIME, but can be converted to a 32 or 64 bit value using
SystemTimeToFileTime and then scaling as appropriate).

the current time is stored in an (internal or external) battery backed
RTC, so that when processor is asleep or off, onboard batteries
continue to power the clock and when board reboots, we determine
current time based on contents of battery backed RTC. Is this correct
so far?

Haven't used the functions you mentioned but the system time (RTC) is
usually maintained using a small backup battery (if your system
supports this) when no main power is applied.


Yes, that is what our system does.

Since CE stores local time, I think this means that when you reboot
you can't know the UTC unless you also have, in some non-volatile
storage, the time zone *and* whether we are currently in DST or not.
So is the standard way to handle this to store time zone and DST state
to non-volatile storage? Are there standard API calls people use for
this?

The timezone and DST details are stored in the registry and these are
used to calculate local time. This has nothing to do with system time.
There are plenty of functions to perform the various conversions but
maybe I am not understanding your question properly.


I was trying to call these functions from OALIoCtlHalInitRTC. Maybe I
didn't try the right functions, but I didn't seem to be able to link
to the ones I wanted.

Hope at least something here helps.

Thanks, we wouldn't survive without the eMVPs. :)
.



Relevant Pages

  • Re: Clock Adjust for HP49G and hp49g+ (50g)
    ... back on last sunday in Oktober, 3.00 h local time. ... to DST on 2nd sunday in March, ... daylight saving time to 1:00 A.M. local standard time, ... I'm not sure of what, if any, effect the DST "fall back" switch ...
    (comp.sys.hp48)
  • Re: DST Adjustments
    ... 'transition' occurs, it saves the next transition time (it saves the October ... current DST flag at that point. ... the current local time to the saved, ... >> way to do it is using local time and system time. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: [OT] How to get uclibc style timezone string (e.g GMT+0IST-1,M3.5.0/01:00:00,M10.5.0/02:00:0
    ... The best reason I can think of is to check in advance whether the local time ... E.g. when the U.S. rules for DST were changed then users would also have ... The Olson time zone files contain also the history of DST rules, ... can convert UTC time to local time correctly for years ago. ...
    (comp.protocols.time.ntp)
  • Re: [SLE] time
    ... > have cmos backedup with Norton Rescue. ... > utc and I switched it to local time. ... If the battery is bad, which is what you said, there is a message from the ... BIOS when you boot that says that the battery is bad and that you must ...
    (SuSE)