ERROR WHEN SETTING DATE

T

tony

HI,

strange bug from device that work for 6 month ..
everytime the device is starting, the user set the date and time.

today, the user set 31/12/2007 14:00 and in the main menu
the date was 01/01/2008 .

what am i missing here ?

the device is not connected to internet or any network.
and im using OpenNETCF.Win32.DateTimeEx.SetLocalTime. and net compact 1.0

thanking in advance.
 
T

tony

Hi,

till now i used DateTime.Now , after reading a little , i tried also
GetLocalTime
but it return the same wrong value of 1/1/2008.

very annoying.

any ideas ?

thanks for your help.
 
G

Guest

It sounds like it's a timezone issue. The CF caches the current DateTime
(at least in 1.0 it did), so if you call out to set the time, DateTime.Now
will always be wrong from that point on. Without seeing code, I can't say
for sure what might be goping wrong though.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com
 
T

tony

except from SetLocalTime and GetLocalTime

i need to call other functions ?

how do i set the timezone, and to what value ?

i can build small program to test it and send the code, just tell me what to
test ? (SetLocalTime, GetLocalTime,DateTime.Now)

thanking in advance.
 
P

Paul G. Tobey [eMVP]

SetTimezoneInformation() will set the time zone (OpenNETCF has a wrapper for
this, too). Check what the Control Panel Date/Time applet says about the
time zone. Have you tried setting the date/time *that* way and seeing if it
works? That would point more-definitely to either a) your code is wrong, or
b) there is a time zone issue.

Paul T.

tony said:
except from SetLocalTime and GetLocalTime

i need to call other functions ?

how do i set the timezone, and to what value ?

i can build small program to test it and send the code, just tell me what
to test ? (SetLocalTime, GetLocalTime,DateTime.Now)

thanking in advance.


It sounds like it's a timezone issue. The CF caches the current DateTime
(at least in 1.0 it did), so if you call out to set the time,
DateTime.Now will always be wrong from that point on. Without seeing
code, I can't say for sure what might be goping wrong though.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



tony said:
Hi,

till now i used DateTime.Now , after reading a little , i tried also
GetLocalTime
but it return the same wrong value of 1/1/2008.

very annoying.

any ideas ?

thanks for your help.


"<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote in message
How are you reading the date? DateTime.Now?


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com


HI,

strange bug from device that work for 6 month ..
everytime the device is starting, the user set the date and time.

today, the user set 31/12/2007 14:00 and in the main menu
the date was 01/01/2008 .

what am i missing here ?

the device is not connected to internet or any network.
and im using OpenNETCF.Win32.DateTimeEx.SetLocalTime. and net compact
1.0

thanking in advance.
 
A

abhishek.nimonkar

Hi

I am facing a similar issue. Though my device works on windows CE 6.0
but i think the problem is related.
my device was also working fine since last few months but now from 1st
Jan, the date that is getting set is one day ahead of what i m trying
to set. the hours and minutes are getting set correctly.
I am using SetLocalTime to set the time. As suggested, i tried setting
the date using Date/Time applet in control panel, but the behaviour is
the same. I am also setting the timezone registry in platform.reg file
to set my timezone after every cold boot.

Any help is appreciated.
Thanks
Abhishek
 
P

Paul G. Tobey [eMVP]

So, you're getting a different value from DateTime.Now than what you
actually see on the Date/Time Control Panel applet? Have you tried exiting
all .NET CF applications and restarting them to see if that changes? When
you set the date/time via the Control Panel to today, the current time, it
automatically is shifting the date around on you? That's not happening to
me (I don't have a CE6 device laying around, but it's working perfectly in
CE5). What time zone are you set for?

Paul T.
 
A

abhishek.nimonkar

Thanks Paul for the reply. Please find the answers to your Questions.

-------you're getting a different value from DateTime.Now than what
you actually see on the Date/Time Control Panel applet?
No I see the same value in both the cases but it is different from
what I am setting. I am using GetLocalTime API.
-------Have you tried exiting all .NET CF applications and restarting
them to see if that changes?
Yes. I have restarted the device and applications and the problem is
still there.
------- When you set the date/time via the Control Panel to today, the
current time, it automatically is shifting the date aound on you?
Yes. If I set the date for today, it sets the date for tomorrow.
------- What time zone are you set for?
India Standard Time. There is no daylight saving in this time zone.

Code snippet.
//////////////////////////////////////////////////////////
SYSTEMTIME st,st1;
st.wYear = 2008;
st.wMonth = 1;
st.wDate = 4;
.....
.....
::SetLocalTime(&st);
::SetLocalTime(&st); // read somewhere that i need to do this twice.

::GetLocalTime(&st1);
printf("st1.wDay = %d\r\n",st1.wDay);// prints 5 here.
//////////////////////////////////////////////////////////

Thanks
Abhishek
 
P

Paul G. Tobey [eMVP]

------- When you set the date/time via the Control Panel to today, the
current time, it automatically is shifting the date aound on you?
Yes. If I set the date for today, it sets the date for tomorrow.

You're really telling me that, when you change the date/time on the control
panel, it doesn't accept what you enter, but instead changes it to another
date? Sorry, I can't believe that.
Code snippet.
//////////////////////////////////////////////////////////
SYSTEMTIME st,st1;
st.wYear = 2008;
st.wMonth = 1;
st.wDate = 4;

wDate is not a field in the SYSTEMTIME structure.
....
....
::SetLocalTime(&st);
::SetLocalTime(&st); // read somewhere that i need to do this twice.

No.

This has the feel of you having some service running in the background on
this unit, the time service, maybe, and it doing something when you change
the date/time. Check what is running on the device besides your programs.

Paul T.
 

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

Top