Re: How to get the time_t value from a Wx::DateTime
Steve Cookson - gmail <[email protected]>
| Newsgroups | gmane.comp.lang.perl.wxperl |
|---|---|
| Message-ID | <[email protected]> |
Hi Dave, GetTicks() returns the number of seconds since the start of 1970. It seems to be the same as GetTimeNow, but as you say, neither seem to be wrapped. However, Perl is so rich in various functions and as you don't seem to need any particular GUI control, I suggest you use something from cpan, eg http://search.cpan.org/~chorny/DateTime-Format-Epoch-0.13/lib/DateTime/Format/Epoch.pm http://search.cpan.org/~bzajac/DateTime-Precise-1.05/lib/DateTime/Precise.pm http://search.cpan.org/~stbey/Date-Calc-6.3/lib/Date/Calc.pod I don't use it them, but they seems to do what you want. Regards Steve. On 31/12/14 22:29, Dave Hayes wrote: > Maybe I'm dense, but I have searched a lot for how to get the time_t > value -out- of a Wx::DateTime object. I've tried GetTicks() which is > in the docs, but this method is not in the Perl version of this. I > even tried unreferencing the scalar reference. > > The only (untested at the moment) idea I can come up with is: > > $dt_object = $some_date_picker_ctrl_widget->GetValue(); # because > GetDate() doesn't work > $now = time(); > $timespan = $dt_i_want->Subtract(Wx::DateTime->new($now)); > $the_time_i_want = $timespan->GetValue() + $now; > > Am I missing something? > > Thanks in advance.