Re: How to get the time_t value from a Wx::DateTime

James Lynes <[email protected]>
Newsgroups gmane.comp.lang.perl.wxperl
Message-ID <CABPysejngnhO0p+PD66EJizRE7aco3P52t8dxFqg3cVTe1aG3A@mail.gmail.com>
For my own education, is this a problem of version? I ask because on my
3.0.1 system, I spent some time last night digging around and in
wx/datetime.h I found:

   GetTicks()
   return (time_t)((m_time/(long)TIME_T_FACTOR.ToLong()) +
WX_TIME_BASE_OFFSET

   where m_time is the internal representation(milliseconds),
             TIME_T_FACTOR is 1000(milliseconds to seconds)
             WX_TIME_BASE_OFFSET is 0

And statements like - Currently we don't know what is the real type of
time_t so prefer to err on the safe side and limit it to 32 bit values...

James


On Fri, Jan 2, 2015 at 11:42 AM, Steve Cookson - gmail <
[email protected]> wrote:

> 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.
>>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.