class LinuxAdmin::TimeDate

Constants

COMMAND
TimeCommandError

Public Class Methods

system_time=(time) click to toggle source
# File lib/linux_admin/time_date.rb, line 25
def self.system_time=(time)
  Common.run!(Common.cmd(COMMAND), :params => ["set-time", "#{time.strftime("%F %T")}", :adjust_system_clock])
rescue AwesomeSpawn::CommandResultError => e
  raise TimeCommandError, e.message
end
system_timezone() click to toggle source
# File lib/linux_admin/time_date.rb, line 14
def self.system_timezone
  system_timezone_detailed.split[0]
end
system_timezone=(zone) click to toggle source
# File lib/linux_admin/time_date.rb, line 31
def self.system_timezone=(zone)
  Common.run!(Common.cmd(COMMAND), :params => ["set-timezone", zone])
rescue AwesomeSpawn::CommandResultError => e
  raise TimeCommandError, e.message
end
system_timezone_detailed() click to toggle source
# File lib/linux_admin/time_date.rb, line 7
def self.system_timezone_detailed
  result = Common.run(Common.cmd(COMMAND), :params => ["status"])
  result.output.split("\n").each do |l|
    return l.split(':')[1].strip if l =~ /Time.*zone/
  end
end
timezones() click to toggle source
# File lib/linux_admin/time_date.rb, line 18
def self.timezones
  result = Common.run!(Common.cmd(COMMAND), :params => ["list-timezones"])
  result.output.split("\n")
rescue AwesomeSpawn::CommandResultError => e
  raise TimeCommandError, e.message
end