Index: Lib/difflib.py =================================================================== --- Lib/difflib.py (revision 77065) +++ Lib/difflib.py (working copy) @@ -1161,18 +1161,18 @@ The unidiff format normally has a header for filenames and modification times. Any or all of these may be specified using strings for - 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification - times are normally expressed in the format returned by time.ctime(). + 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification + times are normally expressed in ISO 8601 compatible timestamps. Example: >>> for line in unified_diff('one two three four'.split(), ... 'zero one tree four'.split(), 'Original', 'Current', - ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003', + ... '1991-01-26 23:30:50', '2003-06-06 10:20:52', ... lineterm=''): ... print line - --- Original Sat Jan 26 23:30:50 1991 - +++ Current Fri Jun 06 10:20:52 2003 + --- Original 1991-01-26 23:30:50 + +++ Current Fri 2003-06-06 10:20:52 @@ -1,4 +1,4 @@ +zero one @@ -1185,8 +1185,12 @@ started = False for group in SequenceMatcher(None,a,b).get_grouped_opcodes(n): if not started: - yield '--- %s %s%s' % (fromfile, fromfiledate, lineterm) - yield '+++ %s %s%s' % (tofile, tofiledate, lineterm) + if fromfiledate: + fromfiledate = '\t%s' % fromfiledate + if tofiledate: + tofiledate = '\t%s' % tofiledate + yield '--- %s%s%s' % (fromfile, fromfiledate, lineterm) + yield '+++ %s%s%s' % (tofile, tofiledate, lineterm) started = True i1, i2, j1, j2 = group[0][1], group[-1][2], group[0][3], group[-1][4] yield "@@ -%d,%d +%d,%d @@%s" % (i1+1, i2-i1, j1+1, j2-j1, lineterm) @@ -1232,8 +1236,8 @@ >>> print ''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1), ... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current', ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:22:46 2003')), - *** Original Sat Jan 26 23:30:50 1991 - --- Current Fri Jun 06 10:22:46 2003 + *** Original Sat Jan 26 23:30:50 1991 + --- Current Fri Jun 06 10:22:46 2003 *************** *** 1,4 **** one @@ -1251,8 +1255,12 @@ prefixmap = {'insert':'+ ', 'delete':'- ', 'replace':'! ', 'equal':' '} for group in SequenceMatcher(None,a,b).get_grouped_opcodes(n): if not started: - yield '*** %s %s%s' % (fromfile, fromfiledate, lineterm) - yield '--- %s %s%s' % (tofile, tofiledate, lineterm) + if fromfiledate: + fromfiledate = '\t%s' % fromfiledate + if tofiledate: + tofiledate = '\t%s' % tofiledate + yield '*** %s%s%s' % (fromfile, fromfiledate, lineterm) + yield '--- %s%s%s' % (tofile, tofiledate, lineterm) started = True yield '***************%s' % (lineterm,)