contrib/convert-mbox-date.py
author Adrian Buehlmann <adrian@cadifra.com>
Sun, 03 Apr 2011 11:51:01 +0200
changeset 55 59814494f238
parent 23 aux/convert-mbox-date.py@a42b9c661bc1
permissions -rw-r--r--
rename aux directory to contrib On Windows, aux is a reserved name and can't be used for files or directories.

#!/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()