Set wxDateTime - with GMT values

Ole Nielsby ole.nielsby at tekare-you-spamminglogisk.dk
Mon Nov 5 09:32:52 PST 2007


Steven Van Ingelgem <steven at vaningelgem.be> wrote:

>I think you should post a feature request to SF with the question to
> add the timezone to the constructors/Setters as this is not very easy
> to achieve I feel.
>
> How I would do it:
>
> Get those 2 values:
> wxLocaltime_r
> wxGmtime_r
>
> Subtract them from each other and add them to your newly constructed
> date. Then it will be in GMT_8 or whatever local timezone you are
> in...

This seems to work for me:

    wxDateTime timestamp(
            date, (wxDateTime::Month)(month - 1), year,
            hour, minute, second, millisecond
        );
    //pray that dayligt saving time switch doesn't happen here
    timestamp.MakeFromTimezone
        ((wxDateTime::TimeZone)(hourshift * 3600));

But a timezoned constructor should definitely be added IMO.

Steve's hack depends on functions that aren't documented in the helpfile,
and my hack might have timewarp issues around daylight saving time
switching - the timestamp could be in the "ghost hour" or the system
might switch in the midst of the routine.

I think I submitted a feature request 7-8 months ago when I wrote the
above code - but I can't find it on sourceforge.








More information about the wx-users mailing list