function date_range_valid in Date 8
Same name and namespace in other branches
- 6.2 date_api.module \date_range_valid()
- 7.3 date_api/date_api.module \date_range_valid()
- 7 date_api/date_api.module \date_range_valid()
- 7.2 date_api/date_api.module \date_range_valid()
Tests validity of a date range string.
Parameters
string $string: A min and max year string like '-3:+1'a.
Return value
bool TRUE if the date range is valid, FALSE otherwise.
2 calls to date_range_valid()
- DateAPITest::testDateAPI in date_api/
lib/ Drupal/ date_api/ Tests/ DateAPITest.php - @todo.
- date_year_range_validate in date_api/
date_api_elements.inc - Element validation function for the date_year_range form element.
File
- date_api/
date_api.module, line 403 - This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.
Code
function date_range_valid($string) {
$matches = preg_match('@^(\\-[0-9]+|[0-9]{4}):([\\+|\\-][0-9]+|[0-9]{4})$@', $string);
return $matches < 1 ? FALSE : TRUE;
}