settings for future and past dates
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-07-17 17:45:38 +02:00
parent 9265181154
commit 764b4c5545
5 changed files with 25 additions and 4 deletions

View File

@ -490,10 +490,13 @@ function qdb_dev_build_answers_for_questionnaire(PDO $pdo, string $qnID, int $va
break;
case 'date_spinner':
$year = 2018 + ($v % 6);
$precision = $config['precision'] ?? 'full';
$dateRange = ($config['dateRange'] ?? 'past') === 'future' ? 'future' : 'past';
$year = $dateRange === 'future'
? ((int)date('Y') + ($v % 5))
: (2018 + ($v % 6));
$month = 1 + ($v % 12);
$day = 1 + ($v % 28);
$precision = $config['precision'] ?? 'full';
$dateValue = match ($precision) {
'year' => sprintf('%04d', $year),
'year_month' => sprintf('%04d-%02d', $year, $month),