Skip to content

Instantly share code, notes, and snippets.

@shuhei
Created September 8, 2013 04:43
Show Gist options
  • Save shuhei/6481898 to your computer and use it in GitHub Desktop.
Save shuhei/6481898 to your computer and use it in GitHub Desktop.
Active Support's inconsistency in Time-Date comparison.
# My local time offset is +0900.
require 'date'
require 'time'
Time.new(2013, 9, 3, 10) > Date.new(2013, 9, 3) # ArgumentError: comparison of Time with Date failed
require 'active_support/time'
Time.new(2013, 9, 3, 10) > Date.new(2013, 9, 3) # true
Time.new(2013, 9, 3, 9) > Date.new(2013, 9, 3) # false
Time.new(2013, 9, 3, 9) > Date.new(2013, 9, 3).to_time # true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment