mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #7582: Use ISO timestamp in diff.py
This commit is contained in:
parent
ff493c9c46
commit
a2637729f2
1 changed files with 12 additions and 4 deletions
|
@ -9,6 +9,12 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, os, time, difflib, optparse
|
import sys, os, time, difflib, optparse
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
def file_mtime(path):
|
||||||
|
t = datetime.fromtimestamp(os.stat(path).st_mtime,
|
||||||
|
timezone.utc)
|
||||||
|
return t.astimezone().isoformat()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
@ -30,10 +36,12 @@ def main():
|
||||||
n = options.lines
|
n = options.lines
|
||||||
fromfile, tofile = args
|
fromfile, tofile = args
|
||||||
|
|
||||||
fromdate = time.ctime(os.stat(fromfile).st_mtime)
|
fromdate = file_mtime(fromfile)
|
||||||
todate = time.ctime(os.stat(tofile).st_mtime)
|
todate = file_mtime(tofile)
|
||||||
fromlines = open(fromfile, 'U').readlines()
|
with open(fromfile, 'U') as ff:
|
||||||
tolines = open(tofile, 'U').readlines()
|
fromlines = ff.readlines()
|
||||||
|
with open(tofile, 'U') as tf:
|
||||||
|
tolines = tf.readlines()
|
||||||
|
|
||||||
if options.u:
|
if options.u:
|
||||||
diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
|
diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue