diff options
author | Barry Warsaw <barry@python.org> | 1996-12-13 18:07:07 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1996-12-13 18:07:07 (GMT) |
commit | 4eb01cd37292ede5608e5b0f9c2fdbc5007a0e9a (patch) | |
tree | 4667b1980cfce5c4be5336af6ab51dc074af3d3c /Lib/test/test_strftime.py | |
parent | 3c700ed6130f9b764326bac4ac1345e19e67d417 (diff) | |
download | cpython-4eb01cd37292ede5608e5b0f9c2fdbc5007a0e9a.zip cpython-4eb01cd37292ede5608e5b0f9c2fdbc5007a0e9a.tar.gz cpython-4eb01cd37292ede5608e5b0f9c2fdbc5007a0e9a.tar.bz2 |
More or less portabilized.
1. If a conversion isn't supported on the current platform, just
ignore it, unless running as a script (i.e. verbose)
2. Don't use time.time() and os.popen('date') to get the raw values.
These will always be different!
Diffstat (limited to 'Lib/test/test_strftime.py')
-rwxr-xr-x | Lib/test/test_strftime.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index c272735..288162c 100755 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -9,10 +9,13 @@ verbose = 0 if __name__ == '__main__': verbose = 1 -now = time.time() -fp = os.popen('date') -fromdate = string.strip(fp.readline()) -fp.close() +now = 850499890.282 # time.time() +fromdate = 'Fri Dec 13 12:58:10 EST 1996' # os.popen('date') + +## now = time.time() +## fp = os.popen('date') +## fromdate = string.strip(fp.readline()) +## fp.close() nowsecs = int(now) gmt = time.gmtime(now) now = time.localtime(now) @@ -26,7 +29,7 @@ wk1offset = jan1[6] - 6 if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] -if now[3] >=12: clock12 = now[3] - 12 +if now[3] > 12: clock12 = now[3] - 12 else: clock12 = now[3] # descriptions are a mixture of those from the BSD/OS v2.0 man page @@ -44,7 +47,7 @@ expectations = ( ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), - ('%I', '%02d' % clock12, 'hour (00-12)'), + ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), @@ -86,7 +89,8 @@ for e in expectations: result = time.strftime(e[0], now) if result == e[1]: continue if result[0] == '%': - print "Does not appear to support '%s' format" % e[0] + if verbose: + print "Does not appear to support '%s' format" % e[0] else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) |