reorder dates so there's no confusion about US date format (#4670)
This commit is contained in:
parent
fd72e08791
commit
a9c8b9224f
|
@ -1,5 +1,6 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import json
|
import json
|
||||||
|
import datetime
|
||||||
|
|
||||||
from Products.CMFPlone.utils import base_hasattr
|
from Products.CMFPlone.utils import base_hasattr
|
||||||
|
|
||||||
|
@ -406,6 +407,15 @@ class ContentListingView(BrowserView):
|
||||||
|
|
||||||
class QueryBuilder(plone.app.querystring.querybuilder.QueryBuilder):
|
class QueryBuilder(plone.app.querystring.querybuilder.QueryBuilder):
|
||||||
def _makequery(self, *args, **kwargs):
|
def _makequery(self, *args, **kwargs):
|
||||||
|
for i, param in enumerate(kwargs.get('query', [])):
|
||||||
|
if param.get('o', '').startswith('plone.app.querystring.operation.date'):
|
||||||
|
date = param.get('v')
|
||||||
|
try:
|
||||||
|
param = dict(param.copy())
|
||||||
|
param['v'] = datetime.datetime.strptime(date, '%m/%d/%Y').strftime('%Y-%m-%d')
|
||||||
|
kwargs.get('query')[i] = param
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
results = plone.app.querystring.querybuilder.QueryBuilder._makequery(self, *args, **kwargs)
|
results = plone.app.querystring.querybuilder.QueryBuilder._makequery(self, *args, **kwargs)
|
||||||
if isinstance(results, ContentListing):
|
if isinstance(results, ContentListing):
|
||||||
# results may have been padded with None, but ContentListing
|
# results may have been padded with None, but ContentListing
|
||||||
|
|
Reference in New Issue