wxDateTime question Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Widgets
Super wx Problem Solver
Super wx Problem Solver
Posts: 387
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

wxDateTime question

Post by Widgets » Mon Nov 26, 2007 8:25 pm

In trying to use the wxDateTime facilities, I've run into a problem I can't seem to resolve in a time zone independent way.

I am in the PST timezone, so if I use:

Code: Select all

      wxDateTime now;
      now = wxDateTime::Now();
      ftr.Printf( "Printed: %s", 
        now.Format( wxDefaultDateTimeFormat, 
        now.IsDST() ? wxDateTime::PDT : wxDateTime::PST ) );
I get
Printed: 11/26/07 12:mm:ss

What I would like to use to make it time zone independent, is:

Code: Select all

     wxDateTime now;
      now = wxDateTime::Now();
      ftr.Printf( "Printed: %s", 
	now.Format()  );
But when I do, I get
Printed: 11/26/07 04:mm:ss
At the time I run the tests, the GMT time is
08:mm:ss PM, the local time is 12:mm:ss PM.

I'm running Win XP and AFAIK, my time zone info is correct.
What it looks like is that the TZ offset is applied, but with the wrong sign.

So I am wondering where the problem lies, what I have missed or how I can fix things to have them work as expected??

TIA
Environment: Win 10 64-bit & Mint 10.2
MSVC Express 2010, 2015, 2017, 2019
wxWidgets 3.1.2
Fight SPAM - report it with wxSR

Widgets
Super wx Problem Solver
Super wx Problem Solver
Posts: 387
Joined: Thu Jun 01, 2006 4:36 pm
Location: Right here!

Post by Widgets » Tue Nov 27, 2007 7:21 pm

Problem has been resolved.

It looks like I had the environment variable TZ set wrong; it was PST-8 instead of PST8.

With this correction, I get the correct time as the default behavior.
Environment: Win 10 64-bit & Mint 10.2
MSVC Express 2010, 2015, 2017, 2019
wxWidgets 3.1.2
Fight SPAM - report it with wxSR

Post Reply