Magical 57.6 minutes in Time

irb(main):80:0> RUBY_VERSION
=> “1.9.3”
irb(main):81:0> system(“uname -a”)
Linux krank 3.5.0-18-generic #29-Ubuntu SMP Fri Oct 19 10:27:31 UTC
2012 i686 i686 i686 GNU/Linux
=> true
irb(main):82:0> require ‘date’
=> false
irb(main):083:0> Time.new(2012, 11, 3, 12, 00) - Time.new(2012, 10, 3,
12, 00)
=> 2678400.0
irb(main):084:0> _ / 3600 / 24
=> 31.0
irb(main):085:0> Time.new(2012, 11, 4, 12, 00) - Time.new(2012, 10, 4,
12, 00)
=> 2682000.0
irb(main):086:0> _ / 3600 / 24
=> 31.041666666666668
irb(main):087:0> Time.new(2013, 1, 4, 12, 00) - Time.new(2012, 12, 4,
12, 00)
=> 2678400.0

On 19.11.2012 14:26, Todd B. wrote:

=> 2678400.0
irb(main):084:0> _ / 3600 / 24
=> 31.0
irb(main):085:0> Time.new(2012, 11, 4, 12, 00) - Time.new(2012, 10,
4, 12, 00)
=> 2682000.0
irb(main):086:0> _ / 3600 / 24
=> 31.041666666666668
irb(main):087:0> Time.new(2013, 1, 4, 12, 00) - Time.new(2012, 12, 4,
12, 00)
=> 2678400.0

If I understand your question (forgive me if not), have a think about
what happened on November 4th this year. As a hint, I live in the UK and
the answer is different on my machine…

On Mon, Nov 19, 2012 at 8:37 AM, Alex G.
[email protected] wrote:

irb(main):083:0> Time.new(2012, 11, 3, 12, 00) - Time.new(2012, 10,
00)
=> 2678400.0

If I understand your question (forgive me if not), have a think about what
happened on November 4th this year. As a hint, I live in the UK and the
answer is different on my machine…


Alex G.

Why not exactly 60 minutes, though?

On 19.11.2012 14:39, Todd B. wrote:

irb(main):82:0> require ‘date’
=> 31.041666666666668
answer is different on my machine…


Alex G.

Why not exactly 60 minutes, though?

Not sure where you get your 57.6mins from to be honest (a rounding
error?). I get 745 hours in that span of seconds (744 hours is 31 days
exactly):

2682000 / 60 / 60
[1] 745
(745-1)/24
[1] 31


Alex G.

Yeah, I see what’s going on. I’m dividing 745 by 24, which is giving
me the average number of days if there was no hour difference.

Thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs