CC-4110: Smart Playlist: some search criteria don't work

- added bunch of validation
- fixed a bug with range modifier not working correctly
This commit is contained in:
James 2012-07-19 16:57:24 -04:00
parent 9fcc851523
commit 2e7cf68777
2 changed files with 59 additions and 15 deletions

View file

@ -305,5 +305,34 @@ class Application_Common_DateHelper
return new DateInterval("PT{$hour}H{$min}M{$sec}S");
}
/**
* returns true or false depending on input is wether in
* valid range of SQL date/time
* @param string $p_datetime
* should be in format of '0000-00-00 00:00:00'
*/
public static function checkDateTimeRangeForSQL($p_datetime){
$info = explode(' ', $p_datetime);
$dateInfo = explode('-', $info[0]);
$timeInfo = explode(':', $info[1]);
$year = $dateInfo[0];
$month = $dateInfo[1];
$day = $dateInfo[2];
// if year is < 1753 or > 9999 it's out of range
if ($year < 1753 || !checkdate($month, $day, $year)) {
return false;
} else {
// check time
$hour = intval($timeInfo[0]);
$min = intval($timeInfo[1]);
$sec = intval($timeInfo[2]);
if ($hour > 23 || $min > 59 || $sec > 59) {
return false;
}
}
return true;
}
}