Another date validation fix for arrival/departure dates

This commit is contained in:
Igor Scheller 2021-12-12 02:59:55 +01:00 committed by msquare
parent f1531ad987
commit 0f280e68dc
1 changed files with 6 additions and 6 deletions

View File

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