Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
77bfb3b9
Commit
77bfb3b9
authored
Jul 13, 2009
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merged c101857 from 2.12 branch
parent
8c821b06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
+3
-2
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
...PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
+29
-0
No files found.
src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
View file @
77bfb3b9
...
@@ -16,6 +16,7 @@ $Id$
...
@@ -16,6 +16,7 @@ $Id$
"""
"""
import
os
import
os
from
datetime
import
datetime
from
AccessControl.Permissions
import
manage_zcatalog_indexes
from
AccessControl.Permissions
import
manage_zcatalog_indexes
from
AccessControl.Permissions
import
view
from
AccessControl.Permissions
import
view
...
@@ -385,10 +386,10 @@ class DateRangeIndex(UnIndex):
...
@@ -385,10 +386,10 @@ class DateRangeIndex(UnIndex):
def
_convertDateTime
(
self
,
value
):
def
_convertDateTime
(
self
,
value
):
if
value
is
None
:
if
value
is
None
:
return
value
return
value
if
isinstance
(
value
,
str
):
if
isinstance
(
value
,
(
str
,
datetime
)
):
dt_obj
=
DateTime
(
value
)
dt_obj
=
DateTime
(
value
)
value
=
dt_obj
.
millis
()
/
1000
/
60
# flatten to minutes
value
=
dt_obj
.
millis
()
/
1000
/
60
# flatten to minutes
if
isinstance
(
value
,
DateTime
):
el
if
isinstance
(
value
,
DateTime
):
value
=
value
.
millis
()
/
1000
/
60
# flatten to minutes
value
=
value
.
millis
()
/
1000
/
60
# flatten to minutes
result
=
int
(
value
)
result
=
int
(
value
)
if
isinstance
(
result
,
long
):
# this won't work (Python 2.3)
if
isinstance
(
result
,
long
):
# this won't work (Python 2.3)
...
...
src/Products/PluginIndexes/DateRangeIndex/tests/test_DateRangeIndex.py
View file @
77bfb3b9
...
@@ -141,6 +141,35 @@ class DRI_Tests( unittest.TestCase ):
...
@@ -141,6 +141,35 @@ class DRI_Tests( unittest.TestCase ):
bad
=
Dummy
(
'bad'
,
long
(
sys
.
maxint
)
+
1
,
long
(
sys
.
maxint
)
+
1
)
bad
=
Dummy
(
'bad'
,
long
(
sys
.
maxint
)
+
1
,
long
(
sys
.
maxint
)
+
1
)
work
.
index_object
(
0
,
bad
)
work
.
index_object
(
0
,
bad
)
def
test_datetime
(
self
):
from
datetime
import
datetime
before
=
datetime
(
2009
,
7
,
11
,
0
,
0
)
start
=
datetime
(
2009
,
7
,
13
,
5
,
15
)
between
=
datetime
(
2009
,
7
,
13
,
5
,
45
)
stop
=
datetime
(
2009
,
7
,
13
,
6
,
30
)
after
=
datetime
(
2009
,
7
,
14
,
0
,
0
)
dummy
=
Dummy
(
'test'
,
start
,
stop
)
work
=
DateRangeIndex
(
'work'
,
'start'
,
'stop'
)
work
.
index_object
(
0
,
dummy
)
assert
work
.
getEntryForObject
(
0
)
==
(
20790915
,
20790990
)
results
,
used
=
work
.
_apply_index
(
{
'work'
:
before
}
)
assert
len
(
results
)
==
0
results
,
used
=
work
.
_apply_index
(
{
'work'
:
start
}
)
assert
len
(
results
)
==
1
results
,
used
=
work
.
_apply_index
(
{
'work'
:
between
}
)
assert
len
(
results
)
==
1
results
,
used
=
work
.
_apply_index
(
{
'work'
:
stop
}
)
assert
len
(
results
)
==
1
results
,
used
=
work
.
_apply_index
(
{
'work'
:
after
}
)
assert
len
(
results
)
==
0
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment