class Time

def local_time_zone

def local_time_zone
  local_time_zone_by_timedatectl || local_time_zone_by_offset
end

def local_time_zone_by_offset

def local_time_zone_by_offset
  ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name
end

def local_time_zone_by_timedatectl

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