summaryrefslogtreecommitdiff
path: root/bin/fmt-metadata
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-07-01 18:17:38 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-07-01 18:17:38 -0400
commit55f9bd8d5226eb49f5899c5ddca89c655ef96e9b (patch)
tree53096770e331f2d571fc9e49af5000cfed1fa0d8 /bin/fmt-metadata
parente4109fab0bece003dc53c78c7cc8608b68328312 (diff)
stuff
Diffstat (limited to 'bin/fmt-metadata')
-rwxr-xr-xbin/fmt-metadata25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/fmt-metadata b/bin/fmt-metadata
new file mode 100755
index 0000000..0682414
--- /dev/null
+++ b/bin/fmt-metadata
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+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]
+
+ next if name.downcase == "parent directory"
+
+ # 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
+
+ puts ("%-22s %s %3s%s" % [ name, datetime, size_numb, size_unit ])
+end