ASAConsole::Test.script do |asa|
asa.connect
log "Local time is #{Time.now.getlocal}"
time = ASAConsole::Util.parse_cisco_time(asa.show('clock')) do |t, tz|
log "Remote time (not adjusted for timezone) is #{t}"
log "Remote timezone string is #{tz}"
result = asa.running_config('all clock').select('clock timezone').config_data
matches = /(?<tz>[\S]+) (?<offset>\-?\d+)/.match(result)
if tz == matches[:tz]
log 'Assuming we are not on summer time...'
offset = matches[:offset].to_i
else
log 'Assuming we are on summer time...'
offset = matches[:offset].to_i + 1
end
log "UTC offset is #{offset}"
t.getlocal - (offset * 3600)
end
log "Remote time (adjusted to the local timezone) is #{time}"
asa.disconnect
end