Browse Source

Fix timestamp display issues with --annotate

tags/nilmdb-1.5.1
Jim Paris 11 years ago
parent
commit
230ec72609
2 changed files with 6 additions and 2 deletions
  1. +5
    -1
      nilmdb/utils/time.py
  2. +1
    -1
      tests/test_cmdline.py

+ 5
- 1
nilmdb/utils/time.py 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")



+ 1
- 1
tests/test_cmdline.py 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")


Loading…
Cancel
Save