Class: Time
- Defined in:
- lib/eac_ruby_utils/patches/time/local_time_zone.rb
Constant Summary collapse
- TIMEDATECTL_TIMEZONE_LINE_PATTERN =
%r{\s*Time zone:\s*(\S+/\S+)\s}.freeze
Class Method Summary collapse
- .local_time_zone ⇒ Object
- .local_time_zone_by_offset ⇒ Object
- .local_time_zone_by_timedatectl ⇒ Object
Class Method Details
.local_time_zone ⇒ Object
10 11 12 |
# File 'lib/eac_ruby_utils/patches/time/local_time_zone.rb', line 10 def local_time_zone local_time_zone_by_timedatectl || local_time_zone_by_offset end |
.local_time_zone_by_offset ⇒ Object
21 22 23 |
# File 'lib/eac_ruby_utils/patches/time/local_time_zone.rb', line 21 def local_time_zone_by_offset ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name end |
.local_time_zone_by_timedatectl ⇒ Object
14 15 16 17 18 19 |
# File 'lib/eac_ruby_utils/patches/time/local_time_zone.rb', line 14 def local_time_zone_by_timedatectl executable = ::EacRubyUtils::Envs.local.executable('timedatectl', '--version') return nil unless executable.exist? TIMEDATECTL_TIMEZONE_LINE_PATTERN.if_match(executable.command.execute!) { |m| m[1] } end |