Browse Source

Parse timestamps with '@' before any other checks

tags/nilmdb-1.4.7^0
Jim Paris 11 years ago
parent
commit
ae9fe89759
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      nilmdb/utils/time.py

+ 8
- 8
nilmdb/utils/time.py View File

@@ -65,6 +65,14 @@ def parse_time(toparse):
if toparse == "max":
return max_timestamp

# If it starts with @, treat it as a NILM timestamp
# (integer microseconds since epoch)
try:
if toparse[0] == '@':
return int(toparse[1:])
except (ValueError, KeyError):
pass

# 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.
@@ -78,14 +86,6 @@ def parse_time(toparse):
except (ValueError, OverflowError):
pass

# If it starts with @, treat it as a NILM timestamp
# (integer microseconds since epoch)
try:
if toparse[0] == '@':
return int(toparse[1:])
except (ValueError, KeyError):
pass

# If it's parseable as a float, treat it as a Unix or NILM
# timestamp based on its range.
try:


Loading…
Cancel
Save