Commit 6c307a65 authored by Yusei Tahara's avatar Yusei Tahara

ZSQLCatalog/SearchKey/DateTimeKey.py: Change date delimiter from a dash to a...

ZSQLCatalog/SearchKey/DateTimeKey.py: Change date delimiter from a dash to a slash to use local timezone automatically.

DateTime('2012-01-01') ignores timezone and DateTime('2012/01/01') does not ignore timezone. Since timezone is a must, change date delimiter from a dash to a slash.
parent 406e48ed
...@@ -36,6 +36,7 @@ from DateTime.DateTime import DateTime, DateTimeError, _cache ...@@ -36,6 +36,7 @@ from DateTime.DateTime import DateTime, DateTimeError, _cache
from Products.ZSQLCatalog.interfaces.search_key import ISearchKey from Products.ZSQLCatalog.interfaces.search_key import ISearchKey
from zope.interface.verify import verifyClass from zope.interface.verify import verifyClass
from Products.ZSQLCatalog.SearchText import parse from Products.ZSQLCatalog.SearchText import parse
import re
MARKER = [] MARKER = []
...@@ -76,6 +77,11 @@ def castDate(value, change_timezone=True): ...@@ -76,6 +77,11 @@ def castDate(value, change_timezone=True):
# Because "2012/01/01 00:00:00 GMT+9" < "2012/01/01 00:00:00 GMT+0". # Because "2012/01/01 00:00:00 GMT+9" < "2012/01/01 00:00:00 GMT+0".
if value.isdigit(): if value.isdigit():
raise DateTimeError raise DateTimeError
if re.match('\d+-\d+$|\d+-\d+-\d+$', value) is not None:
# DateTime('2012-01-01') ignores timezone and DateTime('2012/01/01')
# does not ignore timezone. Since timezone is a must, change date
# delimiter from a dash to a slash.
value = value.replace('-', '/')
value = _DateTime(value, **date_kw) value = _DateTime(value, **date_kw)
except DateTimeError: except DateTimeError:
delimiter_count = countDelimiters(value) delimiter_count = countDelimiters(value)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment