Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
erp5
Commits
98601acc
Commit
98601acc
authored
Jul 20, 2012
by
Yusei Tahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bug on DateTimeKey search tested by testSQLCatalog.TestSQLCatalog.test_relatedDateTimeKey.
parent
8bc42dd8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
product/ZSQLCatalog/SearchKey/DateTimeKey.py
product/ZSQLCatalog/SearchKey/DateTimeKey.py
+22
-4
No files found.
product/ZSQLCatalog/SearchKey/DateTimeKey.py
View file @
98601acc
...
@@ -53,7 +53,7 @@ def _DateTime(*args, **kw):
...
@@ -53,7 +53,7 @@ def _DateTime(*args, **kw):
return
DateTime
(
*
args
,
**
kw
)
return
DateTime
(
*
args
,
**
kw
)
@
profiler_decorator
@
profiler_decorator
def
castDate
(
value
):
def
castDate
(
value
,
change_timezone
=
True
):
if
value
is
None
:
if
value
is
None
:
return
None
return
None
date_kw
=
{
'datefmt'
:
'international'
}
date_kw
=
{
'datefmt'
:
'international'
}
...
@@ -69,6 +69,17 @@ def castDate(value):
...
@@ -69,6 +69,17 @@ def castDate(value):
pass
pass
elif
isinstance
(
value
,
basestring
):
elif
isinstance
(
value
,
basestring
):
try
:
try
:
# This is needed because DateTime(2012) ignores timezone.
# >>> DateTime()
# DateTime('2012/01/30 19:06:34.216686 GMT+9')
# >>> DateTime('2012')
# DateTime('2012/01/01 00:00:00 GMT+0')
# Timezone changed from GMT+9 to GMT+0!
# Then document at "2012/01/01 00:00:00 GMT+9" cannot be found by
# query of '2012'.
# Because "2012/01/01 00:00:00 GMT+9" < "2012/01/01 00:00:00 GMT+0".
if
value
.
isdigit
():
raise
DateTimeError
value
=
_DateTime
(
value
,
**
date_kw
)
value
=
_DateTime
(
value
,
**
date_kw
)
except
DateTimeError
:
except
DateTimeError
:
delimiter_count
=
countDelimiters
(
value
)
delimiter_count
=
countDelimiters
(
value
)
...
@@ -83,7 +94,14 @@ def castDate(value):
...
@@ -83,7 +94,14 @@ def castDate(value):
raise
raise
else
:
else
:
raise
TypeError
,
'Unknown date type: %r'
%
(
value
)
raise
TypeError
,
'Unknown date type: %r'
%
(
value
)
if
change_timezone
:
return
value
.
toZone
(
'UTC'
)
return
value
.
toZone
(
'UTC'
)
else
:
# This is needed. Because if you call toZone('UTC'),
# 2012/12/01 can become 2012/11/30 and then month
# is changed! Month must not be changed. Otherwise
# getMonthLen returns wrong value.
return
value
# (strongly) inspired from DateTime.DateTime.py
# (strongly) inspired from DateTime.DateTime.py
delimiter_list
=
' -/.:,+'
delimiter_list
=
' -/.:,+'
...
@@ -114,7 +132,7 @@ def countDelimiters(value):
...
@@ -114,7 +132,7 @@ def countDelimiters(value):
@
profiler_decorator
@
profiler_decorator
def
getPeriodBoundaries
(
value
):
def
getPeriodBoundaries
(
value
):
first_date
=
castDate
(
value
)
first_date
=
castDate
(
value
,
change_timezone
=
False
)
if
isinstance
(
value
,
dict
):
if
isinstance
(
value
,
dict
):
value
=
value
[
'query'
]
value
=
value
[
'query'
]
# Try to guess how much was given in query.
# Try to guess how much was given in query.
...
@@ -127,7 +145,7 @@ def getPeriodBoundaries(value):
...
@@ -127,7 +145,7 @@ def getPeriodBoundaries(value):
delta
=
delta_list
[
delimiter_count
]
delta
=
delta_list
[
delimiter_count
]
if
callable
(
delta
):
if
callable
(
delta
):
delta
=
delta
(
first_date
)
delta
=
delta
(
first_date
)
return
first_date
,
first_date
+
delta
return
first_date
.
toZone
(
'UTC'
),
(
first_date
+
delta
).
toZone
(
'UTC'
)
@
profiler_decorator
@
profiler_decorator
def
wholePeriod
(
search_key
,
group
,
column
,
value_list
,
exclude
=
False
):
def
wholePeriod
(
search_key
,
group
,
column
,
value_list
,
exclude
=
False
):
...
...
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