Sha256: cf841ce75c70807b0001caa0660450637485e3c21aa57791752fae7399eec2e3
Contents?: true
Size: 858 Bytes
Versions: 5
Compression:
Stored size: 858 Bytes
Contents
module LinuxAdmin class TimeDate extend Common COMMAND = 'timedatectl' TimeCommandError = Class.new(StandardError) def self.system_timezone_detailed result = run(cmd(COMMAND), :params => ["status"]) result.output.split("\n").each do |l| return l.split(':')[1].strip if l =~ /Time.*zone/ end end def self.system_timezone system_timezone_detailed.split[0] end def self.system_time=(time) run!(cmd(COMMAND), :params => ["set-time", "#{time.strftime("%F %T")}", :adjust_system_clock]) rescue AwesomeSpawn::CommandResultError => e raise TimeCommandError, e.message end def self.system_timezone=(zone) run!(cmd(COMMAND), :params => ["set-timezone", zone]) rescue AwesomeSpawn::CommandResultError => e raise TimeCommandError, e.message end end end
Version data entries
5 entries across 5 versions & 1 rubygems