aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-06-17 16:39:36 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-06-17 16:49:21 -0700
commitbf6661c5d75d8e29ebd5f6011f97a85c892663a0 (patch)
treeb015d95137e600879ae8861cc8c27ddded92d725 /activerecord
parent5ae7a9d31d6222b265013ab450f9d30b88113e69 (diff)
downloadrails-bf6661c5d75d8e29ebd5f6011f97a85c892663a0.tar.gz
rails-bf6661c5d75d8e29ebd5f6011f97a85c892663a0.tar.bz2
rails-bf6661c5d75d8e29ebd5f6011f97a85c892663a0.zip
setting the timezone in postgres to whatever ruby thinks the timezone is [#4895 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG5
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb7
2 files changed, 11 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 7d5e550a7c..def519c05d 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,3 +1,8 @@
+*Rails 3.0.0 [RC1] (unreleased)*
+
+* PostgreSQL: ensure the database time zone matches Ruby's time zone. #4895 [Aaron Patterson]
+
+
*Rails 3.0.0 [beta 4] (June 8th, 2010)*
* Fixed that ActiveRecord::Base.compute_type would swallow NoMethodError #4751 [Andrew Bloomgarden, Andrew White]
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index bb8850f134..e84242601b 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -927,7 +927,12 @@ module ActiveRecord
# If using Active Record's time zone support configure the connection to return
# TIMESTAMP WITH ZONE types in UTC.
- execute("SET time zone 'UTC'") if ActiveRecord::Base.default_timezone == :utc
+ if ActiveRecord::Base.default_timezone == :utc
+ execute("SET time zone 'UTC'")
+ else
+ offset = Time.local(2000).utc_offset / 3600
+ execute("SET time zone '#{offset}'")
+ end
end
# Returns the current ID of a table's sequence.