summaryrefslogtreecommitdiff
path: root/bin/fmt-metadata
blob: 7867d6329d130c12279e95f91fc04e98bbc9c001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/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]

	# 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