rails/rails — pull request #13711 by gspiers (2014-01-14 13:12:36+00:00)
Title: Calculation methods on datetime fields should return values in the current timezone.

Calculation methods should act the same as attributes on the model and be timezone aware.

Currently values returned from calculations on models return dates/times in UTC. For example:

Topic.maximum(:written_on) => 2014-01-13 17:56:44 UTC

Selecting that column will return the value converted to the current timezone if time_zone_aware_attributes is true and it's not been excluded with skip_time_zone_conversion_for_attributes:

Topic.pluck(:written_on).first => Mon, 13 Jan 2014 17:56:44 GMT +00:00
or

topic = Topic.first
topic.written_on => Mon, 13 Jan 2014 17:56:44 GMT +00:00

This pull request makes it so calculated values also honor the time_zone_aware_attributes flag and the skip_time_zone_conversion_for_attributes array:

Topic.maximum(:written_on) => Mon, 13 Jan 2014 17:56:44 GMT +00:00

Let me know if it needs any cleaning up or changes. Thanks!