aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/time/zones.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/zones.rb b/activesupport/lib/active_support/core_ext/time/zones.rb
index d2b95698e5..3ffc71407c 100644
--- a/activesupport/lib/active_support/core_ext/time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/time/zones.rb
@@ -35,6 +35,11 @@ module ActiveSupport #:nodoc:
::Time.zone = old_zone
end
+ # Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now.
+ def current
+ ::Time.zone_default ? ::Time.zone.now : ::Time.now
+ end
+
private
def get_zone(time_zone)
return time_zone if time_zone.nil? || time_zone.is_a?(TimeZone)