Need help on Tmie#utc_offset

Hi,

I was reading this method
http://www.ruby-doc.org/core-2.0.0/Time.html#method-i-utc_offset and
trying to understand,but seems not working for me.

Follow the code:

irb(main):001:0> require 'time'
=> true
irb(main):002:0>
irb(main):003:0* t1 = Time.now
=> 2013-09-27 19:42:21 +0530
irb(main):004:0> t2 = t1.utc
=> 2013-09-27 14:12:21 UTC
irb(main):005:0> t2.utc_offset
=> 0
irb(main):006:0> t1.utc_offset
=> 0
irb(main):007:0> t2.utc_offset - t1.utc_offset
=> 0
irb(main):008:0>

I am confused why I am getting `0`,when I am applying `#utc_offset`?
Where did I wrong?

···

--
Posted via http://www.ruby-forum.com/.

Come on! You explicitly converted t1 to UTC...
(Note that according to the docs Time#utc **modifies the receiver**.)

Regards,
Marcus

···

Am 27.09.2013 16:21, schrieb Love U Ruby:

Hi,

I was reading this method
http://www.ruby-doc.org/core-2.0.0/Time.html#method-i-utc_offset and
trying to understand,but seems not working for me.

Follow the code:

irb(main):001:0> require 'time'
=> true
irb(main):002:0>
irb(main):003:0* t1 = Time.now
=> 2013-09-27 19:42:21 +0530
irb(main):004:0> t2 = t1.utc
=> 2013-09-27 14:12:21 UTC
irb(main):005:0> t2.utc_offset
=> 0
irb(main):006:0> t1.utc_offset
=> 0
irb(main):007:0> t2.utc_offset - t1.utc_offset
=> 0
irb(main):008:0>

I am confused why I am getting `0`,when I am applying `#utc_offset`?
Where did I wrong?

--
GitHub: https://github.com/stomar/
PGP: 0x6B3A101A

unknown wrote in post #1122684:

Come on! You explicitly converted t1 to UTC...
(Note that according to the docs Time#utc **modifies the receiver**.)

Regards,
Marcus

Ohh! I see..

irb(main):001:0> require 'time'
=> true
irb(main):002:0> t1= Time.now
=> 2013-09-27 20:32:56 +0530
irb(main):003:0> t1.utc_offset
=> 19800
irb(main):004:0> t2= Time.now
=> 2013-09-27 20:33:44 +0530
irb(main):005:0> t2.utc_offset
=> 19800
irb(main):006:0>

Thanks for the pointer!

···

Am 27.09.2013 16:21, schrieb Love U Ruby:

--
Posted via http://www.ruby-forum.com/.