#!/usr/bin/env ruby # Copyright (c) 2017 Luke Shumaker # # This work is free. You can redistribute it and/or modify it under # the terms of the Do What The Fuck You Want To Public License, # Version 2, as published by Sam Hocevar. See the COPYING file for # more details. require 'time' snapshot = ARGV.first.to_i $stdin.each_line do |line| m = /^ (\S+) +(..-\S+-.... ..:..) +([0-9.-]+)(\S+) *$/.match(line) raise "Malformed line: #{line}" unless m name = m[1] datetime = m[2] size_numb = m[3] size_unit = m[4] # The Unicode.org web server switched the timezone of timestamps # in May 2004 if snapshot < 20040500000000 datetime = Time.parse("#{datetime} +01:00").utc.strftime('%Y-%m-%d %H:%M') else datetime = Time.parse("#{datetime} +00:00").utc.strftime('%Y-%m-%d %H:%M') end # discard the size, I guess. The number of digits precision was # inconsistent over the years. #puts ("%-22s %s %3s%s" % [ name, datetime, size_numb, size_unit ]) puts ("%-22s %s" % [ name, datetime ]) end