function DateRestrictionsBase::newDateObject in Date Restrictions 7
9 calls to DateRestrictionsBase::newDateObject()
- DateRestrictionsHostEntityMinMaxTestCase::_testDateGreaterThanMax in modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test - DateRestrictionsHostEntityMinMaxTestCase::_testDateLowerThanMin in modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test - DateRestrictionsHostEntityMinMaxTestCase::_testIntervalGreaterThanMax in modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test - DateRestrictionsHostEntityMinMaxTestCase::_testIntervalLowerThanMin in modules/
minmax/ tests/ date_restrictions_minmax_host_entity.test - DateRestrictionsStaticMinMaxTestCase::_testDateGreaterThanMax in modules/
minmax/ tests/ date_restrictions_minmax.test
File
- tests/
date_restrictions_base.test, line 141 - Tests for date_restrictions.module.
Class
- DateRestrictionsBase
- Base class for Date Restrictions tests.
Code
function newDateObject($date, $tz = NULL, $force_default_time = TRUE) {
if (is_null($tz)) {
$tz = date_default_timezone();
}
$date = new DateObject($date, $tz);
// Date module fails to set granularity for some dates ("now +2 days",..).
// Enforce granularity to avoid WTFs.
$date
->addGranularity('year');
$date
->addGranularity('month');
$date
->addGranularity('day');
if ($force_default_time) {
// @todo contribute this to date module.
$date
->setTime($this->date_default_hour, $this->date_default_minute);
$date
->addGranularity('hour');
$date
->addGranularity('minute');
}
return $date;
}