Sadaf_N
September 27, 2013, 4:21pm
1
Hi,
I was reading this method
Class: Time (Ruby 2.0.0) 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?
my-ruby
September 27, 2013, 4:41pm
2
Am 27.09.2013 16:21, schrieb Love U Ruby:
irb(main):002:0>
irb(main):008:0>
I am confused why I am getting 0
,when I am applying #utc_offset
?
Where did I wrong?
Come on! You explicitly converted t1 to UTC…
(Note that according to the docs Time#utc modifies the receiver .)
Regards,
Marcus
my-ruby
September 27, 2013, 5:04pm
3
unknown wrote in post #1122684:
Am 27.09.2013 16:21, schrieb Love U Ruby:
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!