On Mon, Nov 12, 2012 at 7:08 AM,  <sto.mar / web.de> wrote:

>>>> t1=Time::parse(current_date+' '+current_time)
>>
>> I think that should be DateTime::parse, but ...
>
> The OP was using Time.parse from the `Time' library.

Really?

1.9.3 (main):0 > Time.parse(remote_date+' '+remote_time)
NoMethodError: undefined method `parse' for Time:Class

>>> Simply use `t1 = Time.new', which returns the current system time.

> But for the considered example, Time.parse returns local time,
> since no time zone was specified in the argument, so it should work.

No, it doesn't, and no, it won't.

1.9.3 (main):0 > t1 = DateTime.parse("2012-11-12 07:30")
=> #<DateTime: 2012-11-12T07:30:00+00:00 ((2456244j,27000s,0n),+0s,2299161j)>
1.9.3 (main):0 > t1.to_s
=> "2012-11-12T07:30:00+00:00"
1.9.3 (main):0 > t2 = Time.new
=> 2012-11-12 07:32:00 -0800
1.9.3 (main):0 > t2 - t1.to_time
=> 28920.165548
1.9.3 (main):0 > (t2 - t1.to_time) / 60 / 60
=> 8.033379318888889
1.9.3 (main):0 >

At least, that's how it works for me. YMMV  :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder / gmail.com
http://about.me/hassanschroeder
twitter: @hassan