For some reason, the comparison always fails, please check this from the Rails console:
irb(main):021:0> @game.game_date.class
=> ActiveSupport::TimeWithZone
irb(main):026:0> @game.game_date
=> Tue, 19 Feb 2013 23:15:00 UTC +00:00
irb(main):022:0> @game.game_date.to_datetime
=> Tue, 19 Feb 2013 23:15:00 +0000
irb(main):019:0> DateTime.now
=> Tue, 19 Feb 2013 23:48:38 +0330
irb(main):020:0> @game.game_date.to_datetime > DateTime.now
=> true
Why is such a comparison always wrong? I tried this too:
@game.game_date.to_time > Time.now.to_tim
The result was true, although it is obvious that it should be false from 23:48> 23:15:00.
Please note that I am using ruby ruby 1.9.3p0 under ubuntu and Rails 3.1
Any help would be greatly appreciated
source
share