aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/helpers/time_value.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/type/helpers/time_value.rb')
-rw-r--r--activemodel/lib/active_model/type/helpers/time_value.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/type/helpers/time_value.rb b/activemodel/lib/active_model/type/helpers/time_value.rb
index c55bb1e136..0a0e58654b 100644
--- a/activemodel/lib/active_model/type/helpers/time_value.rb
+++ b/activemodel/lib/active_model/type/helpers/time_value.rb
@@ -1,3 +1,5 @@
+require "active_support/core_ext/time/zones"
+
module ActiveModel
module Type
module Helpers
@@ -21,11 +23,15 @@ module ActiveModel
end
def is_utc?
- ::Time.zone_default =~ 'UTC'
+ ::Time.zone_default.nil? || ::Time.zone_default =~ 'UTC'
end
def default_timezone
- ::Time.zone_default
+ if is_utc?
+ :utc
+ else
+ :local
+ end
end
def type_cast_for_schema(value)