mirror of
https://github.com/github/rails.git
synced 2026-01-12 08:08:31 -05:00
Compare commits
1 Commits
3-0-github
...
3-0-github
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5799f9a063 |
@@ -61,6 +61,17 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
def quoted_date(value)
|
||||
if value.is_a?(DateTime)
|
||||
# hackily convert this DateTime to a Time so we can properly call
|
||||
# `getlocal` on it to convert it to localtime.
|
||||
#
|
||||
# DateTime has a getutc method, but not a getlocal method, so the
|
||||
# code below will just not even convert it before calling `to_s(:db)`
|
||||
# unless we intervene.
|
||||
#
|
||||
value = Time.parse(value.to_s)
|
||||
end
|
||||
|
||||
if value.acts_like?(:time)
|
||||
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
|
||||
value.respond_to?(zone_conversion_method) ? value.send(zone_conversion_method) : value
|
||||
|
||||
Reference in New Issue
Block a user