$t->skip('', 1);
} catch (sfValidatorError $e) {
    $t->pass('->clean() throws a sfValidatorError if the date is not valid');
    $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');
}
// validate regex
$t->diag('validate regex');
$v->setOption('date_format', '~(?P<day>\\d{2})/(?P<month>\\d{2})/(?P<year>\\d{4})~');
$t->is($v->clean('18/10/2005'), '2005-10-18', '->clean() accepts a regular expression to match dates');
try {
    $v->clean('2005-10-18');
    $t->fail('->clean() throws a sfValidatorError if the date does not match the regex');
    $t->skip('', 2);
} catch (sfValidatorError $e) {
    $t->pass('->clean() throws a sfValidatorError if the date does not match the regex');
    $t->like($e->getMessage(), '/' . preg_quote(htmlspecialchars($v->getOption('date_format'), ENT_QUOTES, 'UTF-8'), '/') . '/', '->clean() returns the expected date format in the error message');
    $t->is($e->getCode(), 'bad_format', '->clean() throws a sfValidatorError');
}
$v->setOption('date_format_error', 'dd/mm/YYYY');
try {
    $v->clean('2005-10-18');
    $t->skip('', 1);
} catch (sfValidatorError $e) {
    $t->like($e->getMessage(), '/' . preg_quote('dd/mm/YYYY', '/') . '/', '->clean() returns the expected date format error if provided');
}
$v->setOption('date_format', null);
// option with_time
$t->diag('option with_time');
$v->setOption('with_time', true);
$t->is($v->clean(array('year' => 2005, 'month' => 10, 'day' => 15, 'hour' => 12, 'minute' => 10, 'second' => 15)), '2005-10-15 12:10:15', '->clean() accepts an array as an input');
$t->is($v->clean(array('year' => '2005', 'month' => '10', 'day' => '15', 'hour' => '12', 'minute' => '10', 'second' => '15')), '2005-10-15 12:10:15', '->clean() accepts an array as an input');