Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

買い物プロセス ゲスト購入でお客様情報入力へ戻ると生年月日が補完されない #1008 #1011

Merged
merged 4 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions data/class/SC_FormParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ public function setDBDate($db_date, $year_key = 'year', $month_key = 'month', $d
if (empty($db_date)) {
return;
}
list($y, $m, $d) = preg_split('/[- ]/', $db_date);
$this->setValue($year_key, $y);
$this->setValue($month_key, $m);
$this->setValue($day_key, $d);

// Smarty3以降は月日が1桁の場合、0埋めされていると補完されないため0を除去する
$objDate = new DateTimeImmutable($db_date);
$this->setValue($year_key, $objDate->format('Y'));
$this->setValue($month_key, $objDate->format('n'));
$this->setValue($day_key, $objDate->format('j'));
}

// キーに対応した値をセットする。
Expand Down
8 changes: 4 additions & 4 deletions tests/class/SC_FormParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ public function testSetDbDate()
$this->objFormParam->addParam('月', 'month', STEXT_LEN, 'aKV', ['EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']);
$this->objFormParam->addParam('日', 'day', STEXT_LEN, 'aKV', ['EXIST_CHECK', 'NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK']);

$this->objFormParam->setDbDate('2019-04-01');
$this->objFormParam->setDbDate('2019-04-01 00:00:00');

$this->assertEquals('2019', $this->objFormParam->getValue('year'));
$this->assertEquals('04', $this->objFormParam->getValue('month'));
$this->assertEquals('01', $this->objFormParam->getValue('day'));
$this->assertSame('2019', $this->objFormParam->getValue('year'));
$this->assertSame('4', $this->objFormParam->getValue('month'));
$this->assertSame('1', $this->objFormParam->getValue('day'));
}

public function testSetDbDateWithEmpty()
Expand Down
Loading