#!/usr/bin/env python # http://inamidst.com/whits/src/ hp=r'

(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):\d{2}Z(?: ([a-z][a-z0-9]+))?' r_header = __import__('re').compile(hp) output = False for line in (line.rstrip('\r\n') for line in __import__('sys').stdin): m = r_header.match(line) if m: print ('
', '
\n
')[output] output, (Y, M, D, h, m, tag) = True, m.groups() if not tag: link = '' % (D, h, m) else: link = '' % (tag, tag) date = __import__('datetime').datetime(*map(int, [Y, M, D, h, m])) format = date.strftime(open('src/format').read().rstrip('\r\n')) print ('

' % (D, h, m)) + link + format + '

' elif output: print line print '
\n'