Fix timestamp display issues with --annotate

This commit is contained in:
Jim Paris 2013-04-09 18:19:32 -04:00
parent d36ece3767
commit 230ec72609
2 changed files with 6 additions and 2 deletions
nilmdb/utils
tests

View File

@ -6,7 +6,7 @@ import time
# Range
min_timestamp = (-2**63)
max_timestamp = (2**62 - 1)
max_timestamp = (2**63 - 1)
# Smallest representable step
epsilon = 1
@ -32,6 +32,10 @@ def timestamp_to_human(timestamp):
"""Convert a timestamp (integer microseconds since epoch) to a
human-readable string, using the local timezone for display
(e.g. from the TZ env var)."""
if timestamp == min_timestamp:
return "(minimum)"
if timestamp == max_timestamp:
return "(maximum)"
dt = datetime_tz.datetime_tz.fromtimestamp(timestamp_to_unix(timestamp))
return dt.strftime("%a, %d %b %Y %H:%M:%S.%f %z")

View File

@ -615,7 +615,7 @@ class TestCmdline(object):
test(8, "10:01:59.9", "10:02:00.1", extra="-m")
# all data put in by tests
self.ok("extract -a /newton/prep --start 2000-01-01 --end 2020-01-01")
self.ok("extract -a /newton/prep --start min --end max")
lines_(self.captured, 43204)
self.ok("extract -c /newton/prep --start 2000-01-01 --end 2020-01-01")
self.match("43200\n")