contrib/convert-mbox-date.py
author frostbane <frostbane@programmer.net>
Fri, 04 Mar 2016 08:15:26 +0900
branchfeature/refactor
changeset 79 3f7593f1b0ae
parent 55 59814494f238
permissions -rw-r--r--
refactor into separate classes add --index and --output option to ishow add --index option to iadd

#!/usr/bin/env python

from mercurial.util import parsedate, datestr
import glob, mailbox

issues = glob.glob('.issues/*')

for i in issues:
	mbox=mailbox.mbox(i)
	for k in xrange(len(mbox)):
		msg = mbox[k]
		print msg['Date']
		d = parsedate(msg['Date'], ['%a, %d %b %Y %H:%M:%S %Z', '%a, %d %b %Y %H:%M:%S'])
		print d
		print datestr(d, '%a, %d %b %Y %H:%M:%S')
		msg.replace_header('Date', datestr(d, '%a, %d %b %Y %H:%M:%S'))
		mbox[k] = msg
	mbox.flush()