Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@godfat
Created November 28, 2010 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save godfat/718960 to your computer and use it in GitHub Desktop.
Save godfat/718960 to your computer and use it in GitHub Desktop.
# http://marklunds.com/articles/one/402
module ActiveRecord
module ConnectionAdapters # :nodoc:
module Quoting
# Convert dates and times to UTC so that the following two will be equivalent:
# Event.all(:conditions => ["start_time > ?", Time.zone.now])
# Event.all(:conditions => ["start_time > ?", Time.now])
def quoted_date(value)
value.respond_to?(:utc) ? value.dup.utc.to_s(:db) : value.to_s(:db)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment