aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2009-12-02 22:20:46 +0000
committerFrancis Irving <francis@mysociety.org>2009-12-02 22:20:46 +0000
commitc2367287b95e73e239aa38261fa64eab3adeecc9 (patch)
tree1f5b5ba89ef5ec0559caa3a6e8678c9fabbc0358 /lib
parent427ce2f9623f12510062aafc9377dde9d210eeca (diff)
Apply Timezone fix patch that used to be just a change in version
control, using instead a proper tested monkey patch in lib
Diffstat (limited to 'lib')
-rw-r--r--lib/timezone_fixes.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/timezone_fixes.rb b/lib/timezone_fixes.rb
new file mode 100644
index 000000000..b830ded4e
--- /dev/null
+++ b/lib/timezone_fixes.rb
@@ -0,0 +1,25 @@
+# Taken from
+# https://rails.lighthouseapp.com/projects/8994/tickets/2946
+# http://github.com/rails/rails/commit/6f97ad07ded847f29159baf71050c63f04282170
+
+# Otherwise times get stored wrong during British Summer Time
+
+# Hopefully fixed in later Rails. There is a test in spec/libs/timezone_fixes.rb
+
+# Monkeypatch!
+module ActiveRecord
+ module ConnectionAdapters # :nodoc:
+ module Quoting
+ def quoted_date(value)
+ value.to_s(:db)
+ 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
+ else
+ value
+ end.to_s(:db)
+ end
+ end
+ end
+end
+