[wxMac] wxDateTime question
H
H at h.com
Mon Jun 4 09:28:31 PDT 2007
In article <eFg8KB.A.ojH.a4wYGB at brage.sunsite.dk>,
vadim at wxwidgets.org (Vadim Zeitlin) wrote:
> On Sat, 26 May 2007 14:36:35 +0200 H <H at h.com> wrote:
>
> H> What do I suppose to get as a result:
> H>
> H> wxDateTime::Now().Subtract(wxDateTime::Now().ToTimezone(wxDateTime::PST))
>
> You're supposed to get the difference in hours between your local time
> zone and PST. E.g. here is what happens here:
>
> % cat dt.cpp
> #include "wx/init.h"
> #include "wx/wxchar.h"
> #include "wx/string.h"
> #include "wx/datetime.h"
>
> int main()
> {
> wxInitializer init;
> if ( !init.IsOk() ) {
> printf("Failed to initialize wxWidgets.\n");
> return 1;
> }
>
> wxDateTime dt = wxDateTime::Now();
> wxPrintf(_T("Current time:\t%s\n"), dt.Format().c_str());
> wxDateTime dtPST = dt.ToTimezone(wxDateTime::PST);
> wxPrintf(_T("And in PST:\t%s\n"), dtPST.Format().c_str());
> wxPrintf(_T("The difference:\t%s\n"), (dt - dtPST).Format().c_str());
>
> return 0;
> }
>
> % g++ -Wall -g `wx-config --cxxflags --libs base` -o dt dt.cpp
> % ./dt
> Current time: Sun Jun 3 15:58:56 2007
> And in PST: Sun Jun 3 05:58:56 2007
> The difference: 10:00:00
>
>
> H> But the result is 0. Probably the OS X uses internally PST?
>
> I'd say it's because of a bug with timezone determination under OS X :-(
> It would be useful to know what does the program above output for you,
> could you please run it?
>
> Thanks,
> VZ
Hi Vadim,
that's the result:
Current time: Mon Jun 4 18:22:27 2007
And in PST: Mon Jun 4 17:22:27 2007
The difference: 01:00:00
Actually the time itself is correct and it should be summer time (so the
time difference should be one hour) but I am DEFINITELY not leaving
anywhere near the pacific! But it's a less than an hour ride by bicycle
to the north sea!
Hartwig
BTW: the OS X settings themselves are correct (MESZ)
More information about the wx-users
mailing list