Permalink
Browse files

Date ranges now use the _betweenDates handler, which is much more for…

…giving

  of empty field values, defaulting to an all-encompassing date range if neither
  value is provided, an "everything after" range if only the start date is
  provided, and a min/max range if both are provided.

  Fixes http://dev.plone.org/ticket/12965
  • Loading branch information...
esteele committed Jun 29, 2012
1 parent e863da9 commit 58a0713124488f48b849239ee735563ae26cbd12
Showing with 27 additions and 1 deletion.
  1. +7 −1 CHANGES.txt
  2. +20 −0 plone/app/querystring/queryparser.py
View
@@ -4,7 +4,13 @@ Changelog
1.0.5 (unreleased)
------------------
-- Nothing changed yet.
+- Date ranges now use the _betweenDates handler, which is much more forgiving
+ of empty field values, defaulting to an all-encompassing date range if neither
+ value is provided, an "everything after" range if only the start date is
+ provided, and a min/max range if both are provided.
+
+ Fixes http://dev.plone.org/ticket/12965
+ [esteele]
1.0.4 (2012-05-07)
@@ -150,6 +150,26 @@ def _moreThanRelativeDate(context, row):
return _between(context, row)
+def _betweenDates(context, row):
+ try:
+ start_date = DateTime(row.values[0])
+ except DateTime.DateTimeError:
+ start_date = DateTime(0)
+ try:
+ end_date = DateTime(row.values[1])
+ except DateTime.DateTimeError:
+ row = Row(index=row.index,
+ operator=row.operator,
+ values=start_date)
+ return _largerThan(context, row)
+ else:
+ row = Row(index=row.index,
+ operator=row.operator,
+ values=(start_date, end_date))
+
+ return _between(context, row)
+
+
def _today(context, row):
now = DateTime()
start_date = now.earliestTime()

0 comments on commit 58a0713

Please sign in to comment.