Created
October 13, 2020 08:15
-
-
Save aileron/553b98492d6e3584b3b5a5c76fa01e3d to your computer and use it in GitHub Desktop.
zsh の history を元にして、開始と終了から時間を出します
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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