Timezone problem - reposted from general development

If you are using wxDev-C++ for your wxWidgets design, please ask your questions here instead of in IDE Related.
Post Reply
robinsoz
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 29, 2007 3:43 pm

Timezone problem - reposted from general development

Post by robinsoz »

I probably don't understand something obvious or am not setting something right...but anyway....

I am using wxDevC++ on Windows XP. I am using the microsoft C++ compiler.

My problem is that my program seems to assume that I am in the Central timezone (US). If the timezone in the computer is set to Pacific time (my timezone), the WxDateTime::Today() function returns the next day between the hours of 10:00 PM and Midnight. If the computer's timezone is set to Central time, the program works as it is supposed to.

The following code fragment displays tomorrow's date on the screen if run between 10:00 and Midnight local time if the computer's timezone is set to Pacific time, otherwise it will display today's date. If the timezone is Central time, it always displays today's date.

wxDateTime testtime;
testtime=wxDateTime::Today();
wxMessageBox(testtime.FormatISODate());

I would like it to always display the local date.
alkaiser
Earned a small fee
Earned a small fee
Posts: 16
Joined: Fri Jan 26, 2007 12:26 am

Post by alkaiser »

Try: wxDateTime::Now() to initialize. i don't think the time of day is set with ::Today().
robinsoz
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 29, 2007 3:43 pm

Post by robinsoz »

I tried Now()...results were the same as with Today(). It seems that for some reason wxWidgets thinks my timezone is set to Central time. (I used to live in Iowa, so this computer was once in the Central timezone.....but is now set to the Pacific timezone.)

How would you query the OS, in wxWidgets, to get the local timezone?
robinsoz
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 29, 2007 3:43 pm

Post by robinsoz »

Tried running the program on another computer - one which has been in the Pacific timezone since I first installed windows on it - and the same executable file gave the correct date.

Is there some sort of Windows bug where the timezone Windows is installed with the first time is permanently etched in its memory somewhere?
alkaiser
Earned a small fee
Earned a small fee
Posts: 16
Joined: Fri Jan 26, 2007 12:26 am

Post by alkaiser »

i'm using xp and when i replied to your first post i tested the program first by changing my own timezone. i had no problem changing back and forth between two time zones.
baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

Post by baka_bai »

I had a similar problem to this though it wasn't because of wxWidgets. It would happen when booting between operating systems on my laptop. Both OS had the same timezone settings but one would always have an accelerated time, for lack of a better phraze, then the other. Ended up having something to do with one OS set to use UTC time and the other being set to use local time settings.

Note sure if that would help but it maybe one possibilty worth looking at.
____
wxWidgest 2.8.2 / 2.8.6u
mingw32-gcc-3.4.2 / gcc 4.1.2
wxDev-CPP beta 6.10.2 / Anjuta
Dev-CPP (4.9.9.2)
XP Pro / Vista / Feodra 8
robinsoz
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Nov 29, 2007 3:43 pm

Post by robinsoz »

I have since taken the executable from the computer I have been developing on and run it on other computers - and it adjusted to the timezone correctly.

The Windows XP installation on this computer is about five and a half years old - somehow this bug has been introduced into the operating system either by an update or something I installed during that time.
Post Reply