rubymotion-community / motion-support

Commonly useful extensions to the standard library for RubyMotion
MIT License
132 stars 28 forks source link

Date/Time class not working as expected #17

Open kapso opened 10 years ago

kapso commented 10 years ago

See issue below where today is greater than tomorrow

(main)> today = Date.today
=> Sat, 04 Jan 2014

(main)> tomorrow = Date.today + 1.day
=> Sun, 05 Jan 2014

(main)> today > tomorrow
=> true

(main)> today.to_time.to_i > tomorrow.to_time.to_i
=> true

I am using the following version - motion-support (0.2.6)

Gemfile:

gem "motion-support", require: false

Rakefile:

require "motion-support/core_ext/time"
Watson1978 commented 10 years ago

When I adjust my MacBook time from local time zone to GMT-08:00 zone and 11pm. Then I can reproduce your problem.

(main)> today = Date.today
=> Thu, 30 Jan 2014
(main)> tomorrow = Date.today + 1.day
=> Fri, 31 Jan 2014
(main)> today.to_time
=> 2014-01-30 23:04:51 -0800
(main)> tomorrow.to_time
=> 2014-01-31 00:00:00 UTC
(main)> today.to_time.to_i
=> 1391151891
(main)> tomorrow.to_time.to_i
=> 1391126400
(main)>

I think this and #18 are same problems.