Permalink
Browse files

added ability to filter in mmddyyyy format for :datetime, :timestamp,…

… and :date fields
  • Loading branch information...
1 parent 06eafd6 commit 2da9c571034b3125d642eadfe3eb27446901010b @jorgeramos jorgeramos committed Nov 26, 2011
@@ -28,6 +28,7 @@
'<option data-additional-fieldset="false"' + (field_operator == "last_week" ? 'selected="selected"' : '') + ' value="last_week">Last week</option>' +
'<option data-additional-fieldset="true" ' + (field_operator == "less_than" ? 'selected="selected"' : '') + ' value="less_than">Less than ... days ago</option>' +
'<option data-additional-fieldset="true" ' + (field_operator == "more_than" ? 'selected="selected"' : '') + ' value="more_than">More than ... days ago</option>' +
+ '<option data-additional-fieldset="true" ' + (field_operator == "mmddyyyy" ? 'selected="selected"' : '') + ' value="mmddyyyy">On specific date (mmddyyyy)</option>' +
'<option disabled="disabled">---------</option>' +
'<option data-additional-fieldset="false"' + (field_operator == "_not_null" ? 'selected="selected"' : '') + ' value="_not_null">Is present</option>' +
'<option data-additional-fieldset="false"' + (field_operator == "_null" ? 'selected="selected"' : '') + ' value="_null" >Is blank</option>' +
@@ -267,6 +267,9 @@ def build_statement(column, type, value, operator)
when 'more_than'
return if value.blank?
[2000.years.ago, value.to_i.days.ago]
+ when 'mmddyyyy'
+ return if (value.blank? || value.match(/([0-9]{8})/).nil?)
+ [Date.strptime(value.match(/([0-9]{8})/)[1], '%m%d%Y').beginning_of_day, Date.strptime(value.match(/([0-9]{8})/)[1], '%m%d%Y').end_of_day]
end
["(#{column} BETWEEN ? AND ?)", *values]
when :enum

0 comments on commit 2da9c57

Please sign in to comment.