aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/helpers/timezone.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel/lib/active_model/type/helpers/timezone.rb')
-rw-r--r--activemodel/lib/active_model/type/helpers/timezone.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/type/helpers/timezone.rb b/activemodel/lib/active_model/type/helpers/timezone.rb
new file mode 100644
index 0000000000..cf87b9715b
--- /dev/null
+++ b/activemodel/lib/active_model/type/helpers/timezone.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require "active_support/core_ext/time/zones"
+
+module ActiveModel
+ module Type
+ module Helpers # :nodoc: all
+ module Timezone
+ def is_utc?
+ ::Time.zone_default.nil? || ::Time.zone_default =~ "UTC"
+ end
+
+ def default_timezone
+ is_utc? ? :utc : :local
+ end
+ end
+ end
+ end
+end