Sha256: 5003c0969b27c067b321e4e36558cfdb4c578467082423d98eb1765476f27f01
Contents?: true
Size: 701 Bytes
Versions: 110
Compression:
Stored size: 701 Bytes
Contents
# frozen_string_literal: true require 'active_support/core_ext/time/zones' require 'eac_ruby_utils/envs' class Time class << self TIMEDATECTL_TIMEZONE_LINE_PATTERN = %r{\s*Time zone:\s*(\S+/\S+)\s}.freeze def local_time_zone local_time_zone_by_timedatectl || local_time_zone_by_offset end 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 def local_time_zone_by_offset ::ActiveSupport::TimeZone[::Time.now.getlocal.gmt_offset].name end end end
Version data entries
110 entries across 110 versions & 3 rubygems