Re: What time is it? Issues with Local time, system time, DST
- From: Andrew Schweitzer <anschweitzer@xxxxxxxxx>
- Date: Wed, 15 Apr 2009 10:04:42 -0700 (PDT)
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).
Yes, that is what our system does.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.
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. :)
.
- References:
- What time is it? Issues with Local time, system time, DST
- From: Andrew Schweitzer
- Re: What time is it? Issues with Local time, system time, DST
- From: trentpope
- What time is it? Issues with Local time, system time, DST
- Prev by Date: Re: Debugging DAT file failures
- Next by Date: Re: What time is it? Issues with Local time, system time, DST
- Previous by thread: Re: What time is it? Issues with Local time, system time, DST
- Next by thread: Re: What time is it? Issues with Local time, system time, DST
- Index(es):
Relevant Pages
|