Add one-sided ms timerange

This commit is contained in:
Matthias 2019-10-19 19:38:16 +02:00
parent c48876b196
commit d8630ef847
2 changed files with 8 additions and 0 deletions

View File

@ -42,6 +42,8 @@ class TimeRange:
(r'^-(\d{10})$', (None, 'date')),
(r'^(\d{10})-$', ('date', None)),
(r'^(\d{10})-(\d{10})$', ('date', 'date')),
(r'^-(\d{13})$', (None, 'date')),
(r'^(\d{13})-$', ('date', None)),
(r'^(\d{13})-(\d{13})$', ('date', 'date')),
]
for rex, stype in syntax:

View File

@ -20,5 +20,11 @@ def test_parse_timerange_incorrect() -> None:
timerange = TimeRange.parse_timerange('1231006505000-1233360000000')
assert TimeRange('date', 'date', 1231006505, 1233360000) == timerange
timerange = TimeRange.parse_timerange('1231006505000-')
assert TimeRange('date', None, 1231006505, 0) == timerange
timerange = TimeRange.parse_timerange('-1231006505000')
assert TimeRange(None, 'date', 0, 1231006505) == timerange
with pytest.raises(Exception, match=r'Incorrect syntax.*'):
TimeRange.parse_timerange('-')