Skip to content

Commit e8183c3

Browse files
committed
ACP2E-3561: Customer Segment edition fails with daterange
1 parent 2d62730 commit e8183c3

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

lib/internal/Magento/Framework/Data/Form/Element/Date.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66

77
/**
8-
* Magento data selector form element
8+
* Copyright 2011 Adobe
9+
* All Rights Reserved.
910
*/
1011

1112
namespace Magento\Framework\Data\Form\Element;
@@ -121,7 +122,7 @@ public function getValue($format = null)
121122
return '';
122123
}
123124
if (null === $format) {
124-
$format = $this->getDateFormat();
125+
$format = $this->getDateFormat() ?: $this->getFormat();
125126
$format .= ($format && $this->getTimeFormat()) ? ' ' : '';
126127
$format .= $this->getTimeFormat() ? $this->getTimeFormat() : '';
127128
}

lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/DateTest.php

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -125,4 +125,43 @@ protected function getFormMock($exactly)
125125

126126
return $formMock;
127127
}
128+
129+
/**
130+
* @dataProvider providerGetValue
131+
*/
132+
public function testGetValue($dateFormat, $format, $timeFormat, $expectedFormat)
133+
{
134+
$dateTime = new \DateTime('2025-10-13 10:36:00', new \DateTimeZone('America/Los_Angeles'));
135+
$this->model->setValue($dateTime);
136+
$this->model->setDateFormat($dateFormat);
137+
$this->model->setFormat($format);
138+
$this->model->setTimeFormat($timeFormat);
139+
140+
$this->localeDateMock->expects($this->once())
141+
->method('formatDateTime')
142+
->with(
143+
$this->equalTo($dateTime),
144+
$this->isNull(),
145+
$this->isNull(),
146+
$this->isNull(),
147+
$this->equalTo($dateTime->getTimezone()),
148+
$this->equalTo($expectedFormat)
149+
)
150+
->willReturn('2025-10-13 10:36:00');
151+
152+
$this->model->getValue();
153+
}
154+
155+
public function providerGetValue()
156+
{
157+
return [
158+
[null, 'yyyy-mm-dd', 'hh:mm:ss', 'yyyy-mm-dd hh:mm:ss'],
159+
[null, 'yy-mm-dd', null, 'yy-mm-dd'],
160+
['yyyy-mm-dd', null, null, 'yyyy-mm-dd'],
161+
['yyyy-mm-dd', 'yy-mm-dd', 'hh:mm:ss', 'yyyy-mm-dd hh:mm:ss'],
162+
['yyyy-mm-dd', 'yy-mm-dd', null, 'yyyy-mm-dd']
163+
];
164+
}
165+
166+
128167
}

0 commit comments

Comments
 (0)