Allow hour precision queries to use space separator

This commit is contained in:
discopatrick 2017-04-27 00:04:46 +01:00
parent 6a71504545
commit c3771f722c
2 changed files with 8 additions and 1 deletions

View file

@ -534,7 +534,7 @@ class Period(object):
"""
precisions = ('year', 'month', 'day', 'hour', 'minute')
date_formats = (('%Y',), ('%Y-%m',), ('%Y-%m-%d',), ('%Y-%m-%dT%H', 'dummy-format'), ('%Y-%m-%dT%H:%M',))
date_formats = (('%Y',), ('%Y-%m',), ('%Y-%m-%d',), ('%Y-%m-%dT%H', '%Y-%m-%d %H'), ('%Y-%m-%dT%H:%M',))
def __init__(self, date, precision):
"""Create a period with the given date (a `datetime` object) and

View file

@ -59,6 +59,7 @@ class DateIntervalTest(unittest.TestCase):
self.assertExcludes('1999-12..2000-02', '2000-03-01T00:00:00')
def test_hour_precision_intervals(self):
# test with 'T' separator
self.assertExcludes('2000-01-01T12..2000-01-01T13',
'2000-01-01T11:59:59')
self.assertContains('2000-01-01T12..2000-01-01T13',
@ -74,6 +75,12 @@ class DateIntervalTest(unittest.TestCase):
self.assertExcludes('2000-01-01T12..2000-01-01T13',
'2000-01-01T14:30:00')
# test with ' ' (space) separator
self.assertExcludes('2000-01-01 12..2000-01-01 13',
'2000-01-01T11:59:59')
self.assertContains('2000-01-01 12..2000-01-01 13',
'2000-01-01T12:00:00')
def test_minute_precision_intervals(self):
self.assertExcludes('2000-01-01T12:30..2000-01-01T12:31',
'2000-01-01T12:29:59')