aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-02-17 16:48:01 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2013-02-17 16:48:01 +0000
commitbd328f4342074f3234046afb7d8a30bb573545e3 (patch)
tree0d645dbda227ae3605381daecf41fb17365a2c18 /activerecord/CHANGELOG.md
parent7a32c6300c2b11dc1660338535c653a0132df196 (diff)
downloadrails-bd328f4342074f3234046afb7d8a30bb573545e3.tar.gz
rails-bd328f4342074f3234046afb7d8a30bb573545e3.tar.bz2
rails-bd328f4342074f3234046afb7d8a30bb573545e3.zip
Add CHANGELOG entry for 41ff6a10216f48f43605a1f9cd6094765cab750f
[ci skip]
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md40
1 files changed, 40 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 4489ca1aff..5c0dfa73b6 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,45 @@
## Rails 4.0.0 (unreleased) ##
+* Simplified type casting code for timezone aware attributes to use the
+ `in_time_zone` method if it is available. This introduces a subtle change
+ of behavior when using `Date` instances as they are directly converted to
+ `ActiveSupport::TimeWithZone` instances without first being converted to
+ `Time` instances. For example:
+
+ # Rails 3.2 behavior
+ >> Date.today.to_time.in_time_zone
+ => Wed, 13 Feb 2013 07:00:00 UTC +00:00
+
+ # Rails 4.0 behavior
+ >> Date.today.in_time_zone
+ => Wed, 13 Feb 2013 00:00:00 UTC +00:00
+
+ On the plus side it now behaves the same whether you pass a `String` date
+ or an actual `Date` instance. For example:
+
+ # Rails 3.2 behavior
+ >> Date.civil(2013, 2, 13).to_time.in_time_zone
+ => Wed, 13 Feb 2013 07:00:00 UTC +00:00
+ >> Time.zone.parse("2013-02-13")
+ => Wed, 13 Feb 2013 00:00:00 UTC +00:00
+
+ # Rails 4.0 behavior
+ >> Date.civil(2013, 2, 13).in_time_zone
+ => Wed, 13 Feb 2013 00:00:00 UTC +00:00
+ >> "2013-02-13".in_time_zone
+ => Wed, 13 Feb 2013 00:00:00 UTC +00:00
+
+ If you need the old behavior you can convert the dates to times manually.
+ For example:
+
+ >> Post.new(created_at: Date.today).created_at
+ => Wed, 13 Feb 2013 00:00:00 UTC +00:00
+
+ >> Post.new(created_at: Date.today.to_time).created_at
+ => Wed, 13 Feb 2013 07:00:00 UTC +00:00
+
+ *Andrew White*
+
* Preloading `has_many :through` associations with conditions won't
cache the `:through` association. This will prevent invalid
subsets to be cached.