Beispiel #1
0
 /**
  * Test sanitizeDate functionality.
  *
  * @return void
  */
 public function testSanitizeDate()
 {
     $tests = ['[2014]' => '2014-01-01', 'n.d.' => null, 'may 7, 1981' => '1981-05-07', 'July 1570' => '1570-07-01', 'incomprehensible garbage' => null, '1930/12/21' => '1930-12-21', '1964?' => '1964-01-01', '1947-3' => '1947-03-01', '1973-02-31' => '1973-02-01', '1973-31-31' => '1973-01-01', '1964-zz' => '1964-01-01', '1964-01-zz' => '1964-01-01', 'Winter 2012' => '2012-01-01', '05-1901' => '1901-05-01', '5-1901' => '1901-05-01', '05/1901' => '1901-05-01', '5/1901' => '1901-05-01', '2nd Quarter 2004' => '2004-01-01', 'Nov 2009 and Dec 2009' => '2009-01-01'];
     foreach ($tests as $in => $out) {
         $this->assertEquals($out === null ? null : $out . 'T00:00:00Z', Utils::sanitizeDate($in));
     }
 }
Beispiel #2
0
 /**
  * Support method for initFullDateFilters() -- normalize a date for use in a
  * year/month/day date range.
  *
  * @param string $date Value to check for valid date.
  *
  * @return string      Formatted date.
  */
 protected function formatDateForFullDateRange($date)
 {
     // Make sure date is valid; default to wildcard otherwise:
     $date = SolrUtils::sanitizeDate($date);
     return $date === null ? '*' : $date;
 }