This may be a well known thing but it surprised me.

Apparently, the time zone of DateTime.now is GMT, but the time zone of

DateTime.new(y, m, d, h, m, s) is local.

Below, I store DateTime.now in x. Then I construct a new DateTime

object using the various components of x. You might expect that x - y

would be 0 or very close to it, but in fact it is very close to the

offset of my time zone (US Central) from GMT, which is .25 day (or 360

min if you multiply .25 day * (1440 min/day)). This implies that

DateTime.now is in GMT and DateTime.new(y, m, d, h, m, s) is in local

time.

Can anyone point me to definitive documentation about this behavior?

Thanks,

Wes

x = DateTime.now

=> #<DateTime: 212070424110293/86400000,-1/4,2299161>y = DateTime.new(x.year, x.month, x.day, x.hour, x.min, x.sec, x.sec_fraction

)

=> #<DateTime: 212070402509707/86400000,293/86400000,2299161>x - y

=> Rational(10800293, 43200000)(x - y).to_f

=> 0.250006782407407(x - y).to_f * 1440

=> 360.009766666667y - y

=> Rational(0, 1)

P. S. Another unusual thing is this:

(DateTime.now - DateTime.new).to_f

=> 2454519.30391494

What’s that???