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
Labels
Merge Requests
140
Merge Requests
140
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
6083a15b
Commit
6083a15b
authored
Jan 18, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DateTimeKey: don't depend on DateTime internals
use calendar module and public DateTime API instead.
parent
01d10932
Pipeline
#26211
failed with stage
in 0 seconds
Changes
1
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
product/ZSQLCatalog/SearchKey/DateTimeKey.py
product/ZSQLCatalog/SearchKey/DateTimeKey.py
+9
-5
No files found.
product/ZSQLCatalog/SearchKey/DateTimeKey.py
View file @
6083a15b
...
...
@@ -31,18 +31,22 @@ from __future__ import absolute_import
import
six
from
six
import
string_types
as
basestring
import
calendar
from
.SearchKey
import
SearchKey
from
Products.ZSQLCatalog.Query.SimpleQuery
import
SimpleQuery
from
Products.ZSQLCatalog.Query.ComplexQuery
import
ComplexQuery
from
zLOG
import
LOG
from
DateTime.DateTime
import
DateTime
,
DateTimeError
,
_cache
from
DateTime.DateTime
import
DateTime
,
DateTimeError
from
DateTime
import
Timezones
from
Products.ZSQLCatalog.interfaces.search_key
import
ISearchKey
from
zope.interface.verify
import
verifyClass
from
Products.ZSQLCatalog.SearchText
import
parse
MARKER
=
[]
timezone_dict
=
_cache
.
_zmap
# We use standard DateTime timezone, with also some timezones that were
# included before and are used (at least) in the test suite.
timezone_set
=
set
([
tz
.
lower
()
for
tz
in
Timezones
()]
+
[
'cet'
,
'cest'
])
date_completion_format_dict
=
{
None
:
[
'01/01/%s'
,
'01/%s'
],
...
...
@@ -84,7 +88,7 @@ def castDate(value, change_timezone=True):
delimiter_count
=
countDelimiters
(
value
)
if
delimiter_count
is
not
None
and
delimiter_count
<
2
:
split_value
=
value
.
split
()
if
split_value
[
-
1
].
lower
()
in
timezone_
dic
t
:
if
split_value
[
-
1
].
lower
()
in
timezone_
se
t
:
value
=
'%s %s'
%
(
date_completion_format_dict
[
date_kw
.
get
(
'datefmt'
)][
delimiter_count
]
%
(
' '
.
join
(
split_value
[:
-
1
]),
),
split_value
[
-
1
])
else
:
value
=
date_completion_format_dict
[
date_kw
.
get
(
'datefmt'
)][
delimiter_count
]
%
(
value
,
)
...
...
@@ -106,7 +110,7 @@ def castDate(value, change_timezone=True):
delimiter_list
=
' -/.:,+'
def
getMonthLen
(
datetime
):
return
datetime
.
_month_len
[
datetime
.
isLeapYear
()][
datetime
.
month
()
]
return
calendar
.
monthrange
(
datetime
.
year
(),
datetime
.
month
())[
1
]
def
getYearLen
(
datetime
):
return
365
+
datetime
.
isLeapYear
()
...
...
@@ -119,7 +123,7 @@ def countDelimiters(value):
split_value
=
value
.
split
()
if
not
split_value
:
return
None
if
split_value
[
-
1
].
lower
()
in
timezone_
dic
t
:
if
split_value
[
-
1
].
lower
()
in
timezone_
se
t
:
value
=
' '
.
join
(
split_value
[:
-
1
])
# Count delimiters
delimiter_count
=
0
...
...
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