DateTime.Now

  • Thread starter Thread starter MDB
  • Start date Start date
M

MDB

Hello All, I have a problem with Datetime.now. For some reason it is
showing 1 hour ahead. For example, the system clock is showing 12:00 which
is correct but when I call DateTime.now it is showing 1:00. Anyone know
what could cause this? It just started happening when Daylight Savings Time
went into effect.
 
Was the app running "through" the time change (i.e you started it befeor the
change and noticed the difference afterward)?

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
Yes it was, and when I rebooted it, it still was an hour off (ahead and
hour). Also, I do not know if it matters however, I am using intermec 760s
which have a registry save program that keeps track of the time in case of
cold boots.
 
I'm guessing that you aren't set for the right timezone. Check that
setting, along with the Automatically adjust for Daylight Saving Time
checkbox.

Paul T.
 
Yes they are set in the right time zone, I have units in the eastern and
pacific time zones and it happened on all of them. Additionally, there is
no Automatically adjust for daylight savings time checkbox and it is done
automatically already. The system clock in the right hand corner and by
clicking Start-->Settings-->Clock the time is set correctly. It is just
when the app is using DateTime.Now, it is a hour ahead of time.
 
Yes, the regional settings are correct and even the time displaying in the
clock is correct however, when I call DateTime.Now, it is an hour ahead of
time.
 
That sounds like the DST conversion, then, is being done incorrectly by the
..NET CF. You might try using some of the date/time stuff in OpenNETCF to
call GetLocalTime() and GetSystemTime(). I think that there's a
GetTimeZoneInformation(), too. I'm thinking that, if you get all of those,
you'll spot the problem. GetSystemTime() should give GMT. GetLocalTime()
should return what you see on the system tray clock or in the Date/Time
Control Panel applet. GetTimeZoneInformation() may have a bad entry in it.
If you post the results from all of those calls, we might spot something...

Paul T.
 
Okay, thanks, I kind of thought it was the .netcf too however, I didn't know
if anyone else has ran into this. I will check out OpenNETCF.

Thanks Again
 
In the "Known Issues", in "Core OS" there is talk of "SetSystemTime call can
cause daylight saving time drift".

http://msdn.microsoft.com/library/d...eintro5/html/wce50conMacallanReleaseNotes.asp

I'm having a similar problem in that I'm taking a date/time from a server
and attempting to sync the date/time on an Intermec 730 to the date/time of
the server.

I'm using SetSystemTime from the core.dll, and yep, it's adding an hour onto
the time I'm setting. It's very frustrating.

I'm having to do a second check on the time I've just set, and if it doesn't
match the time I've just set, then reduce the hour by one. It's a daft bug.

-M.
 
Thanks


BigM said:
In the "Known Issues", in "Core OS" there is talk of "SetSystemTime call
can
cause daylight saving time drift".

http://msdn.microsoft.com/library/d...eintro5/html/wce50conMacallanReleaseNotes.asp

I'm having a similar problem in that I'm taking a date/time from a server
and attempting to sync the date/time on an Intermec 730 to the date/time
of
the server.

I'm using SetSystemTime from the core.dll, and yep, it's adding an hour
onto
the time I'm setting. It's very frustrating.

I'm having to do a second check on the time I've just set, and if it
doesn't
match the time I've just set, then reduce the hour by one. It's a daft
bug.

-M.
 
Seems like you could turn off automatic DST correction in the shell to
prevent that sort of problem, since time correction is really being applied
at the time server. If there's no checkbox to turn it off, you might try
setting HKLM/Software/Microsoft/Clock/AutoDST, a DWORD value, to 0, rather
than 1. I don't have source for the PPC shell, but that's the flag set on
Windows CE.NET and it might work the same on PPC.

Paul T.
 
Back
Top