* Search for messages within a date range. Only one internal date and
* one RFC 2822 date can be specified per query.
*
- * @param integer $month Month (from 1-12).
- * @param integer $day Day of month (from 1-31).
- * @param integer $year Year (4-digit year).
- * @param string $range Either:
+ * @param DateTime $date DateTime or Horde_Date object.
+ * @param string $range Either:
* <pre>
* Horde_Imap_Client_Search_Query::DATE_BEFORE,
* Horde_Imap_Client_Search_Query::DATE_ON, or
* IMAP date (usually arrival time).
* @param boolean $not If true, do a 'NOT' search of the range.
*/
- public function dateSearch($month, $day, $year, $range, $header = true,
- $not = false)
+ public function dateSearch($date, $range, $header = true, $not = false)
{
$type = $header ? 'header' : 'internal';
if (!isset($this->_search['date'])) {
$this->_search['date'] = array();
}
$this->_search['date'][$header ? 'header' : 'internal'] = array(
- 'date' => date("d-M-y", mktime(0, 0, 0, $month, $day, $year)),
+ 'date' => $date->format('d-M-y'),
'range' => $range,
'not' => $not
);
$query->size('1024', true);
$query->size('4096', false);
$query->sequence(array(1, 5, 50, 51, 52, 55, 54, 53, 55, 55, 100, 500, 501));
-$query->dateSearch(6, 15, 2008, Horde_Imap_Client_Search_Query::DATE_BEFORE, true, true);
-$query->dateSearch(6, 20, 2008, Horde_Imap_Client_Search_Query::DATE_ON, false);
+$date = new DateTime('2008-06-15');
+$query->dateSearch($date, Horde_Imap_Client_Search_Query::DATE_BEFORE, true, true);
+$date = new DateTime('2008-06-20');
+$query->dateSearch($date, Horde_Imap_Client_Search_Query::DATE_ON, false);
// Add 2 simple OR queries
$query2 = new Horde_Imap_Client_Search_Query();
$query2->text('Test3', false, true);