Browse Source

Accept "min" and "max" as timestamps on command line

tags/nilmdb-1.4.2
Jim Paris 11 years ago
parent
commit
2d72891162
2 changed files with 7 additions and 0 deletions
  1. +5
    -0
      nilmdb/utils/time.py
  2. +2
    -0
      tests/test_cmdline.py

+ 5
- 0
nilmdb/utils/time.py View File

@@ -60,6 +60,11 @@ def parse_time(toparse):
timestamp, the current local timezone is assumed (e.g. from the TZ
env var).
"""
if toparse == "min":
return min_timestamp
if toparse == "max":
return max_timestamp

# If string isn't "now" and doesn't contain at least 4 digits,
# consider it invalid. smartparse might otherwise accept
# empty strings and strings with just separators.


+ 2
- 0
tests/test_cmdline.py View File

@@ -233,6 +233,8 @@ class TestCmdline(object):
eq_(parse_time("1333648800.0"), test)
eq_(parse_time("1333648800000000"), test)
eq_(parse_time("@1333648800000000"), test)
eq_(parse_time("min"), nilmdb.utils.time.min_timestamp)
eq_(parse_time("max"), nilmdb.utils.time.max_timestamp)
with assert_raises(ValueError):
parse_time("@hashtag12345")



Loading…
Cancel
Save