Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rails#759 -

There are two issues here:

#1) ActiveSupport::Date current method has a misleading conditional. Time.zone is always returned because config.time_zone is set by default on a project.

#2) ActiveSupport::Date does not override the Date.today method. This means that the core ruby library's .today method is called which may be based off of a different time zone than what's set in config.time_zone.

Submitting a pull request.
  • Loading branch information...
commit 151723ed688eb161d9e6adc80a780912d9346940 1 parent ae65c0b
@leepfrog leepfrog authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 activesupport/lib/active_support/core_ext/date/calculations.rb
View
9 activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -36,9 +36,14 @@ def tomorrow
::Date.current.tomorrow
end
- # Returns Time.zone.today when <tt>Time.zone</tt> or <tt>config.time_zone</tt> are set, otherwise just returns Date.today.
+ # Returns Time.zone.today because <tt>config.time_zone</tt> is always set by default
def current
- ::Time.zone ? ::Time.zone.today : ::Date.today
+ Time.zone.today
+ end
+
+ # Overrides the core Ruby Date.today by returning back Time.zone.today which allows yesterday, tomorrow, and today to all be based off of the same relative date
+ def today
+ ::Date.current
end
end

0 comments on commit 151723e

Please sign in to comment.
Something went wrong with that request. Please try again.