Skip to content

Instantly share code, notes, and snippets.

@aileron
Created October 13, 2020 08:15
Show Gist options
  • Save aileron/553b98492d6e3584b3b5a5c76fa01e3d to your computer and use it in GitHub Desktop.
Save aileron/553b98492d6e3584b3b5a5c76fa01e3d to your computer and use it in GitHub Desktop.
zsh の history を元にして、開始と終了から時間を出します
require 'time'
wd = ["日", "月", "火", "水", "木", "金", "土"]
result = {}
while line = gets
begin
time = Time.parse(line)
date = time.strftime '%Y-%m-%d'
result[date] ||= []
result[date].push time
rescue
nil
end
end
result.each do |key, times|
print "#{key}(#{wd[times.min.wday]})\t#{times.min.strftime('%H:%M')}\t#{times.max.strftime('%H:%M')}\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment