Another date validation fix for arrival/departure dates

main
Igor Scheller 3 years ago committed by msquare
parent f1531ad987
commit 0f280e68dc

@ -152,13 +152,13 @@ function User_validate_planned_arrival_date($planned_arrival_date)
$teardown = $config->get('teardown_end'); $teardown = $config->get('teardown_end');
/** @var Carbon $buildup */ /** @var Carbon $buildup */
if (!empty($buildup) && $buildup->greaterThan(Carbon::createFromTimestamp($planned_arrival_date))) { if (!empty($buildup) && Carbon::createFromTimestamp($planned_arrival_date)->lessThan($buildup->setTime(0,0))) {
// Planned arrival can not be before buildup start date // Planned arrival can not be before buildup start date
return new ValidationResult(false, $buildup->getTimestamp()); return new ValidationResult(false, $buildup->getTimestamp());
} }
/** @var Carbon $teardown */ /** @var Carbon $teardown */
if (!empty($teardown) && $teardown->lessThan(Carbon::createFromTimestamp($planned_arrival_date))) { if (!empty($teardown) && Carbon::createFromTimestamp($planned_arrival_date)->greaterThanOrEqualTo($teardown->addDay()->setTime(0,0))) {
// Planned arrival can not be after teardown end date // Planned arrival can not be after teardown end date
return new ValidationResult(false, $teardown->getTimestamp()); return new ValidationResult(false, $teardown->getTimestamp());
} }
@ -190,14 +190,14 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
$teardown = $config->get('teardown_end'); $teardown = $config->get('teardown_end');
/** @var Carbon $buildup */ /** @var Carbon $buildup */
if (!empty($buildup) && $buildup->greaterThan(Carbon::createFromTimestamp($planned_departure_date))) { if (!empty($buildup) && Carbon::createFromTimestamp($planned_departure_date)->lessThan($buildup->setTime(0,0))) {
// Planned arrival can not be before buildup start date // Planned departure can not be before buildup start date
return new ValidationResult(false, $buildup->getTimestamp()); return new ValidationResult(false, $buildup->getTimestamp());
} }
/** @var Carbon $teardown */ /** @var Carbon $teardown */
if (!empty($teardown) && $teardown->lessThan(Carbon::createFromTimestamp($planned_departure_date))) { if (!empty($teardown) && Carbon::createFromTimestamp($planned_departure_date)->greaterThanOrEqualTo($teardown->addDay()->setTime(0,0))) {
// Planned arrival can not be after teardown end date // Planned departure can not be after teardown end date
return new ValidationResult(false, $teardown->getTimestamp()); return new ValidationResult(false, $teardown->getTimestamp());
} }

Loading…
Cancel
Save