SetLocalTime api

E

Empi

Hi,

I'm using SetLocalTime API in order to update an iPaq's clock according to
user's request.

Whenever the user updates the time, I should update another device's clock
using rs232.

I noticed the following:
When changing from summer to winter and the other way around (e.g. 1 sept 08
<==> 1 Jan 08),
DateTime.Now returns 1 hour less / more than the hour I set using the
setlocal time...
e.g. when moving from Sept to Jan it moves back 1 hour, and add an hour when
moving from Sept to Jan...
DateTime.Now that suppose to return local time as was set returns +- 1 hour.

More over, this is happening when Regional settings are set to Pacific US
(G.M.T -8) and doesn't happen
when using G.M.T + 2 (Cairo for example).

1- Why DateTime.Now return something else than what was set by setlocaltime?
2- How can I be sure that GMT + 2 will work for all dates?
3- I've read that SetLocalTime need to be called twice in order to fix a
relevant bug (it update daylight saving according to the original date and
not the new one). I tried it, but it didn;'t solve the problem.

Any clues?


Thank you very much.

Empi
 
P

Paul G. Tobey [eMVP]

It's Daylight Saving Time (or Summer Time, or any number of other terms used
to indicate that, at some times of the year, the clocks are moved forward or
backward an hour). You can look up Daylight Saving Time on something like
Wikipedia, if you want a history and more-detailed explanation. Various
parts of the world do this at various times of the year. You need to take
suitable action based on what's right for your overall system. Perhaps you
should be using SetSystemTime, rather than SetLocalTime, or maybe you should
allow for the automatic Daylight Saving Time shift, and then change the
local time a second time (I don't think this is a bug; it's much more-likely
that you'd want the automatic DST transition to happen, than it is that
you'd be calling SetLocalTime over and over and over and each time setting
it such that the DST adjustment has to happen; that seems much more like a
weird test case, not a real usage scenario). You'll have to tell us more
about *why* you're calling SetLocalTime() for us to really address what you
should do...

Paul T.
 
E

Empi

Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time using my
application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
P

Paul G. Tobey [eMVP]

No, Windows Mobile has no option exposed to disable it. I'm not sure that
the option found on generic Windows CE would work or not (and that's, as I
said, the wrong way to address this, best I can tell). You could try to
look up that registry entry for generic Windows CE on MSDN, probably in the
time server registry settings or maybe the shell registry settings.

OK, so you're doing exactly what the Date/Time Control Panel applet does, so
you shouldn't expect to be able to do better than what it does. I presume
that you see the same shift of time when you change it there, right? You
could, I suppose, check the return value of GetTimeZoneInformation() before
and after the time/date change to see whether you've shifted from daylight
time to standard time or vice versa and then set the time again to avoid the
hour jumping. If you change the date/time and the result of
GetTimeZoneInformation() is the same before and after, I don't think you
have to do anything.

Paul T.

Empi said:
Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time using
my application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
It's Daylight Saving Time (or Summer Time, or any number of other terms
used to indicate that, at some times of the year, the clocks are moved
forward or backward an hour). You can look up Daylight Saving Time on
something like Wikipedia, if you want a history and more-detailed
explanation. Various parts of the world do this at various times of the
year. You need to take suitable action based on what's right for your
overall system. Perhaps you should be using SetSystemTime, rather than
SetLocalTime, or maybe you should allow for the automatic Daylight Saving
Time shift, and then change the local time a second time (I don't think
this is a bug; it's much more-likely that you'd want the automatic DST
transition to happen, than it is that you'd be calling SetLocalTime over
and over and over and each time setting it such that the DST adjustment
has to happen; that seems much more like a weird test case, not a real
usage scenario). You'll have to tell us more about *why* you're calling
SetLocalTime() for us to really address what you should do...

Paul T.
 
E

Empi

Thanks!


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:uL5%23TZ%[email protected]...
No, Windows Mobile has no option exposed to disable it. I'm not sure that
the option found on generic Windows CE would work or not (and that's, as I
said, the wrong way to address this, best I can tell). You could try to
look up that registry entry for generic Windows CE on MSDN, probably in
the time server registry settings or maybe the shell registry settings.

OK, so you're doing exactly what the Date/Time Control Panel applet does,
so you shouldn't expect to be able to do better than what it does. I
presume that you see the same shift of time when you change it there,
right? You could, I suppose, check the return value of
GetTimeZoneInformation() before and after the time/date change to see
whether you've shifted from daylight time to standard time or vice versa
and then set the time again to avoid the hour jumping. If you change the
date/time and the result of GetTimeZoneInformation() is the same before
and after, I don't think you have to do anything.

Paul T.

Empi said:
Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time using
my application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
It's Daylight Saving Time (or Summer Time, or any number of other terms
used to indicate that, at some times of the year, the clocks are moved
forward or backward an hour). You can look up Daylight Saving Time on
something like Wikipedia, if you want a history and more-detailed
explanation. Various parts of the world do this at various times of the
year. You need to take suitable action based on what's right for your
overall system. Perhaps you should be using SetSystemTime, rather than
SetLocalTime, or maybe you should allow for the automatic Daylight
Saving Time shift, and then change the local time a second time (I don't
think this is a bug; it's much more-likely that you'd want the automatic
DST transition to happen, than it is that you'd be calling SetLocalTime
over and over and over and each time setting it such that the DST
adjustment has to happen; that seems much more like a weird test case,
not a real usage scenario). You'll have to tell us more about *why*
you're calling SetLocalTime() for us to really address what you should
do...

Paul T.

Hi,

I'm using SetLocalTime API in order to update an iPaq's clock according
to user's request.

Whenever the user updates the time, I should update another device's
clock using rs232.

I noticed the following:
When changing from summer to winter and the other way around (e.g. 1
sept 08 <==> 1 Jan 08),
DateTime.Now returns 1 hour less / more than the hour I set using the
setlocal time...
e.g. when moving from Sept to Jan it moves back 1 hour, and add an hour
when moving from Sept to Jan...
DateTime.Now that suppose to return local time as was set returns +- 1
hour.

More over, this is happening when Regional settings are set to Pacific
US (G.M.T -8) and doesn't happen
when using G.M.T + 2 (Cairo for example).

1- Why DateTime.Now return something else than what was set by
setlocaltime?
2- How can I be sure that GMT + 2 will work for all dates?
3- I've read that SetLocalTime need to be called twice in order to fix
a relevant bug (it update daylight saving according to the original
date and not the new one). I tried it, but it didn;'t solve the
problem.

Any clues?


Thank you very much.

Empi
 
E

Empi

Isn't it "easier" just to set it twice?

If I need to call 2 api's anyway...

BTW,

calling setlocaltime twice doesn't solve it...

I'm trying now to set a delay between those 2 calls, maybe it is related to
it.

This daylight saving is sometimes *#lsdqj2341%#$ !
I wonder if it saves as much as we think or maybe all these savings are
going to programmers like me that must handle
it... ;-)



Thanks.


Empi


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:uL5%23TZ%[email protected]...
No, Windows Mobile has no option exposed to disable it. I'm not sure that
the option found on generic Windows CE would work or not (and that's, as I
said, the wrong way to address this, best I can tell). You could try to
look up that registry entry for generic Windows CE on MSDN, probably in
the time server registry settings or maybe the shell registry settings.

OK, so you're doing exactly what the Date/Time Control Panel applet does,
so you shouldn't expect to be able to do better than what it does. I
presume that you see the same shift of time when you change it there,
right? You could, I suppose, check the return value of
GetTimeZoneInformation() before and after the time/date change to see
whether you've shifted from daylight time to standard time or vice versa
and then set the time again to avoid the hour jumping. If you change the
date/time and the result of GetTimeZoneInformation() is the same before
and after, I don't think you have to do anything.

Paul T.

Empi said:
Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time using
my application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message news:[email protected]...
It's Daylight Saving Time (or Summer Time, or any number of other terms
used to indicate that, at some times of the year, the clocks are moved
forward or backward an hour). You can look up Daylight Saving Time on
something like Wikipedia, if you want a history and more-detailed
explanation. Various parts of the world do this at various times of the
year. You need to take suitable action based on what's right for your
overall system. Perhaps you should be using SetSystemTime, rather than
SetLocalTime, or maybe you should allow for the automatic Daylight
Saving Time shift, and then change the local time a second time (I don't
think this is a bug; it's much more-likely that you'd want the automatic
DST transition to happen, than it is that you'd be calling SetLocalTime
over and over and over and each time setting it such that the DST
adjustment has to happen; that seems much more like a weird test case,
not a real usage scenario). You'll have to tell us more about *why*
you're calling SetLocalTime() for us to really address what you should
do...

Paul T.

Hi,

I'm using SetLocalTime API in order to update an iPaq's clock according
to user's request.

Whenever the user updates the time, I should update another device's
clock using rs232.

I noticed the following:
When changing from summer to winter and the other way around (e.g. 1
sept 08 <==> 1 Jan 08),
DateTime.Now returns 1 hour less / more than the hour I set using the
setlocal time...
e.g. when moving from Sept to Jan it moves back 1 hour, and add an hour
when moving from Sept to Jan...
DateTime.Now that suppose to return local time as was set returns +- 1
hour.

More over, this is happening when Regional settings are set to Pacific
US (G.M.T -8) and doesn't happen
when using G.M.T + 2 (Cairo for example).

1- Why DateTime.Now return something else than what was set by
setlocaltime?
2- How can I be sure that GMT + 2 will work for all dates?
3- I've read that SetLocalTime need to be called twice in order to fix
a relevant bug (it update daylight saving according to the original
date and not the new one). I tried it, but it didn;'t solve the
problem.

Any clues?


Thank you very much.

Empi
 
P

Paul G. Tobey [eMVP]

Other applications could be waiting on that event. It might be a good idea
to set the time only as often as you actually need to. It just depends on
what those other applications might do in response to a time change.

It takes time for the time service or the shell, depending on which version
of Windows CE we're talking about, to actually detect the adjustment,
calculate whether the new time should be DST or standard time, figure out if
that means a change from the current state of that flag and, if so, change
the clock by the right amount. There are various things that you might try:
delay, as you're doing now, detect the time server's call to change the time
and react to that, etc.

Ah, you live somewhere that it is used, huh? I live in Arizona, which long
ago decided that we have plenty of daylight, thank you very much. Our time
doesn't ever shift. I'm all in favor of dumping it.

Paul T.

Empi said:
Isn't it "easier" just to set it twice?

If I need to call 2 api's anyway...

BTW,

calling setlocaltime twice doesn't solve it...

I'm trying now to set a delay between those 2 calls, maybe it is related
to it.

This daylight saving is sometimes *#lsdqj2341%#$ !
I wonder if it saves as much as we think or maybe all these savings are
going to programmers like me that must handle
it... ;-)



Thanks.


Empi


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:uL5%23TZ%[email protected]...
No, Windows Mobile has no option exposed to disable it. I'm not sure
that the option found on generic Windows CE would work or not (and
that's, as I said, the wrong way to address this, best I can tell). You
could try to look up that registry entry for generic Windows CE on MSDN,
probably in the time server registry settings or maybe the shell registry
settings.

OK, so you're doing exactly what the Date/Time Control Panel applet does,
so you shouldn't expect to be able to do better than what it does. I
presume that you see the same shift of time when you change it there,
right? You could, I suppose, check the return value of
GetTimeZoneInformation() before and after the time/date change to see
whether you've shifted from daylight time to standard time or vice versa
and then set the time again to avoid the hour jumping. If you change the
date/time and the result of GetTimeZoneInformation() is the same before
and after, I don't think you have to do anything.

Paul T.

Empi said:
Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time using
my application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message It's Daylight Saving Time (or Summer Time, or any number of other terms
used to indicate that, at some times of the year, the clocks are moved
forward or backward an hour). You can look up Daylight Saving Time on
something like Wikipedia, if you want a history and more-detailed
explanation. Various parts of the world do this at various times of
the year. You need to take suitable action based on what's right for
your overall system. Perhaps you should be using SetSystemTime, rather
than SetLocalTime, or maybe you should allow for the automatic Daylight
Saving Time shift, and then change the local time a second time (I
don't think this is a bug; it's much more-likely that you'd want the
automatic DST transition to happen, than it is that you'd be calling
SetLocalTime over and over and over and each time setting it such that
the DST adjustment has to happen; that seems much more like a weird
test case, not a real usage scenario). You'll have to tell us more
about *why* you're calling SetLocalTime() for us to really address what
you should do...

Paul T.

Hi,

I'm using SetLocalTime API in order to update an iPaq's clock
according to user's request.

Whenever the user updates the time, I should update another device's
clock using rs232.

I noticed the following:
When changing from summer to winter and the other way around (e.g. 1
sept 08 <==> 1 Jan 08),
DateTime.Now returns 1 hour less / more than the hour I set using the
setlocal time...
e.g. when moving from Sept to Jan it moves back 1 hour, and add an
hour when moving from Sept to Jan...
DateTime.Now that suppose to return local time as was set returns +- 1
hour.

More over, this is happening when Regional settings are set to Pacific
US (G.M.T -8) and doesn't happen
when using G.M.T + 2 (Cairo for example).

1- Why DateTime.Now return something else than what was set by
setlocaltime?
2- How can I be sure that GMT + 2 will work for all dates?
3- I've read that SetLocalTime need to be called twice in order to fix
a relevant bug (it update daylight saving according to the original
date and not the new one). I tried it, but it didn;'t solve the
problem.

Any clues?


Thank you very much.

Empi
 
E

Empi

Well than... I'm moving to Arizona...
Hope the company will agree to shift with me.

:-D

Thanks a lot.

Empi

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:u7%[email protected]...
Other applications could be waiting on that event. It might be a good
idea to set the time only as often as you actually need to. It just
depends on what those other applications might do in response to a time
change.

It takes time for the time service or the shell, depending on which
version of Windows CE we're talking about, to actually detect the
adjustment, calculate whether the new time should be DST or standard time,
figure out if that means a change from the current state of that flag and,
if so, change the clock by the right amount. There are various things
that you might try: delay, as you're doing now, detect the time server's
call to change the time and react to that, etc.

Ah, you live somewhere that it is used, huh? I live in Arizona, which
long ago decided that we have plenty of daylight, thank you very much.
Our time doesn't ever shift. I'm all in favor of dumping it.

Paul T.

Empi said:
Isn't it "easier" just to set it twice?

If I need to call 2 api's anyway...

BTW,

calling setlocaltime twice doesn't solve it...

I'm trying now to set a delay between those 2 calls, maybe it is related
to it.

This daylight saving is sometimes *#lsdqj2341%#$ !
I wonder if it saves as much as we think or maybe all these savings are
going to programmers like me that must handle
it... ;-)



Thanks.


Empi


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
No, Windows Mobile has no option exposed to disable it. I'm not sure
that the option found on generic Windows CE would work or not (and
that's, as I said, the wrong way to address this, best I can tell). You
could try to look up that registry entry for generic Windows CE on MSDN,
probably in the time server registry settings or maybe the shell
registry settings.

OK, so you're doing exactly what the Date/Time Control Panel applet
does, so you shouldn't expect to be able to do better than what it does.
I presume that you see the same shift of time when you change it there,
right? You could, I suppose, check the return value of
GetTimeZoneInformation() before and after the time/date change to see
whether you've shifted from daylight time to standard time or vice versa
and then set the time again to avoid the hour jumping. If you change
the date/time and the result of GetTimeZoneInformation() is the same
before and after, I don't think you have to do anything.

Paul T.

Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time
using my application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message It's Daylight Saving Time (or Summer Time, or any number of other
terms used to indicate that, at some times of the year, the clocks are
moved forward or backward an hour). You can look up Daylight Saving
Time on something like Wikipedia, if you want a history and
more-detailed explanation. Various parts of the world do this at
various times of the year. You need to take suitable action based on
what's right for your overall system. Perhaps you should be using
SetSystemTime, rather than SetLocalTime, or maybe you should allow for
the automatic Daylight Saving Time shift, and then change the local
time a second time (I don't think this is a bug; it's much more-likely
that you'd want the automatic DST transition to happen, than it is
that you'd be calling SetLocalTime over and over and over and each
time setting it such that the DST adjustment has to happen; that seems
much more like a weird test case, not a real usage scenario). You'll
have to tell us more about *why* you're calling SetLocalTime() for us
to really address what you should do...

Paul T.

Hi,

I'm using SetLocalTime API in order to update an iPaq's clock
according to user's request.

Whenever the user updates the time, I should update another device's
clock using rs232.

I noticed the following:
When changing from summer to winter and the other way around (e.g. 1
sept 08 <==> 1 Jan 08),
DateTime.Now returns 1 hour less / more than the hour I set using the
setlocal time...
e.g. when moving from Sept to Jan it moves back 1 hour, and add an
hour when moving from Sept to Jan...
DateTime.Now that suppose to return local time as was set returns +-
1 hour.

More over, this is happening when Regional settings are set to
Pacific US (G.M.T -8) and doesn't happen
when using G.M.T + 2 (Cairo for example).

1- Why DateTime.Now return something else than what was set by
setlocaltime?
2- How can I be sure that GMT + 2 will work for all dates?
3- I've read that SetLocalTime need to be called twice in order to
fix a relevant bug (it update daylight saving according to the
original date and not the new one). I tried it, but it didn;'t solve
the problem.

Any clues?


Thank you very much.

Empi
 
P

Paul G. Tobey [eMVP]

Don't see why not. Weather probably not that different. ;-)

Paul T.

Empi said:
Well than... I'm moving to Arizona...
Hope the company will agree to shift with me.

:-D

Thanks a lot.

Empi

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:u7%[email protected]...
Other applications could be waiting on that event. It might be a good
idea to set the time only as often as you actually need to. It just
depends on what those other applications might do in response to a time
change.

It takes time for the time service or the shell, depending on which
version of Windows CE we're talking about, to actually detect the
adjustment, calculate whether the new time should be DST or standard
time, figure out if that means a change from the current state of that
flag and, if so, change the clock by the right amount. There are various
things that you might try: delay, as you're doing now, detect the time
server's call to change the time and react to that, etc.

Ah, you live somewhere that it is used, huh? I live in Arizona, which
long ago decided that we have plenty of daylight, thank you very much.
Our time doesn't ever shift. I'm all in favor of dumping it.

Paul T.

Empi said:
Isn't it "easier" just to set it twice?

If I need to call 2 api's anyway...

BTW,

calling setlocaltime twice doesn't solve it...

I'm trying now to set a delay between those 2 calls, maybe it is related
to it.

This daylight saving is sometimes *#lsdqj2341%#$ !
I wonder if it saves as much as we think or maybe all these savings are
going to programmers like me that must handle
it... ;-)



Thanks.


Empi


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
No, Windows Mobile has no option exposed to disable it. I'm not sure
that the option found on generic Windows CE would work or not (and
that's, as I said, the wrong way to address this, best I can tell).
You could try to look up that registry entry for generic Windows CE on
MSDN, probably in the time server registry settings or maybe the shell
registry settings.

OK, so you're doing exactly what the Date/Time Control Panel applet
does, so you shouldn't expect to be able to do better than what it
does. I presume that you see the same shift of time when you change it
there, right? You could, I suppose, check the return value of
GetTimeZoneInformation() before and after the time/date change to see
whether you've shifted from daylight time to standard time or vice
versa and then set the time again to avoid the hour jumping. If you
change the date/time and the result of GetTimeZoneInformation() is the
same before and after, I don't think you have to do anything.

Paul T.

Hi and thanks...

Yes. I do know what daylight saving is.

I found no option on the iPaq 2190 to enable/disable daylight saving.

I simply need an option for the user to set system's date and time
using my application.



"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam
DOT com> wrote in message
It's Daylight Saving Time (or Summer Time, or any number of other
terms used to indicate that, at some times of the year, the clocks
are moved forward or backward an hour). You can look up Daylight
Saving Time on something like Wikipedia, if you want a history and
more-detailed explanation. Various parts of the world do this at
various times of the year. You need to take suitable action based on
what's right for your overall system. Perhaps you should be using
SetSystemTime, rather than SetLocalTime, or maybe you should allow
for the automatic Daylight Saving Time shift, and then change the
local time a second time (I don't think this is a bug; it's much
more-likely that you'd want the automatic DST transition to happen,
than it is that you'd be calling SetLocalTime over and over and over
and each time setting it such that the DST adjustment has to happen;
that seems much more like a weird test case, not a real usage
scenario). You'll have to tell us more about *why* you're calling
SetLocalTime() for us to really address what you should do...

Paul T.

Hi,

I'm using SetLocalTime API in order to update an iPaq's clock
according to user's request.

Whenever the user updates the time, I should update another device's
clock using rs232.

I noticed the following:
When changing from summer to winter and the other way around (e.g. 1
sept 08 <==> 1 Jan 08),
DateTime.Now returns 1 hour less / more than the hour I set using
the setlocal time...
e.g. when moving from Sept to Jan it moves back 1 hour, and add an
hour when moving from Sept to Jan...
DateTime.Now that suppose to return local time as was set returns +-
1 hour.

More over, this is happening when Regional settings are set to
Pacific US (G.M.T -8) and doesn't happen
when using G.M.T + 2 (Cairo for example).

1- Why DateTime.Now return something else than what was set by
setlocaltime?
2- How can I be sure that GMT + 2 will work for all dates?
3- I've read that SetLocalTime need to be called twice in order to
fix a relevant bug (it update daylight saving according to the
original date and not the new one). I tried it, but it didn;'t solve
the problem.

Any clues?


Thank you very much.

Empi
 

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