Mercurial > hg
comparison hgext/patchbomb.py @ 9818:72d670c43f6e
patchbomb: normalize date format in generated mboxes
mbox format should use time.asctime(). Unfortunately, this function writes
2-characters day of week on Windows while unix one writes a single character.
Normalize to Windows version since the other one can hardly be written with
strftime().
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sun, 08 Nov 2009 18:08:24 +0100 |
parents | 6064de41b7e4 |
children | 4600e6222efb 4ddfad7ebd98 |
comparison
equal
deleted
inserted
replaced
9817:912ce84eebae | 9818:72d670c43f6e |
---|---|
449 fp.close() | 449 fp.close() |
450 elif opts.get('mbox'): | 450 elif opts.get('mbox'): |
451 ui.status(_('Writing '), subj, ' ...\n') | 451 ui.status(_('Writing '), subj, ' ...\n') |
452 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+') | 452 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+') |
453 generator = email.Generator.Generator(fp, mangle_from_=True) | 453 generator = email.Generator.Generator(fp, mangle_from_=True) |
454 date = time.ctime(start_time[0]) | 454 # Should be time.asctime(), but Windows prints 2-characters day |
455 # of month instead of one. Make them print the same thing. | |
456 date = time.strftime('%a %b %d %H:%M:%S %Y', | |
457 time.localtime(start_time[0])) | |
455 fp.write('From %s %s\n' % (sender_addr, date)) | 458 fp.write('From %s %s\n' % (sender_addr, date)) |
456 generator.flatten(m, 0) | 459 generator.flatten(m, 0) |
457 fp.write('\n\n') | 460 fp.write('\n\n') |
458 fp.close() | 461 fp.close() |
459 else: | 462 else: |