[wxMac] wxDateTime question
Vadim Zeitlin
vadim at wxwidgets.org
Sun Jun 3 07:08:56 PDT 2007
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
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
More information about the wx-users
mailing list