Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit a6a67fd

Browse files
🔃 [EngCom] Public Pull Requests - 2.3-develop
Accepted Public Pull Requests: - magento/magento2#11306: Error date time to save (by @raumatbel) Fixed GitHub Issues: - magento/magento2#10485: Error: Invalid input datetime format of value '25/07/+00201717' (reported by @denchev) has been fixed in magento/magento2#11306 by @raumatbel in 2.3-develop branch Related commits: 1. b237558 - magento/magento2#10580: Set product as new "from" and "to" not being interpreted correctly (reported by @gwharton) has been fixed in magento/magento2#11306 by @raumatbel in 2.3-develop branch Related commits: 1. b237558 - magento/magento2#10686: 2.1.8 : Cart Rules date is invalid format in French (reported by @LSERRE) has been fixed in magento/magento2#11306 by @raumatbel in 2.3-develop branch Related commits: 1. b237558 - magento/magento2#10754: Magento 2.1.8 : Cart Rules + New Customer (Please enter a valid date) Locale AU (reported by @gilbertsohal) has been fixed in magento/magento2#11306 by @raumatbel in 2.3-develop branch Related commits: 1. b237558
2 parents f66f057 + 4aaa109 commit a6a67fd

File tree

2 files changed

+45
-15
lines changed
  • dev/tests/integration/testsuite/Magento/Framework/Stdlib/DateTime/Filter
  • lib/internal/Magento/Framework/Stdlib/DateTime

2 files changed

+45
-15
lines changed

dev/tests/integration/testsuite/Magento/Framework/Stdlib/DateTime/Filter/DateTimeTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@ public function localeDatetimeFilterProvider()
7070
['fr_FR', '01/02/2010 15:30', '2010-02-01 15:30:00'],
7171
['fr_FR', '01/02/2010 1:00', '2010-02-01 01:00:00'],
7272
['fr_FR', '01/02/2010 01:00', '2010-02-01 01:00:00'],
73+
['en_US', '11/28/2010', '2010-11-28 00:00:00'],
74+
['en_US', '11/28/2010 1:00am', '2010-11-28 01:00:00'],
75+
['en_US', '11/28/2010 01:00am', '2010-11-28 01:00:00'],
76+
['es_ES', '28/11/2010', '2010-11-28 00:00:00'],
77+
['es_ES', '28/11/2010 23:12:00', '2010-11-28 23:12:00'],
78+
['es_ES', '28/11/2010 23:12', '2010-11-28 23:12:00'],
7379
['de_DE', '01/02/2010 15:30', '2010-02-01 15:30:00'],
7480
['en_US', '2017-09-01T15:30:00.000Z', '2017-09-01 15:30:00'],
75-
['fr_FR', '2017-09-01T15:30:00.000Z', '2017-09-01 15:30:00'],
81+
['fr_FR', '2017-09-01T15:30:00.000Z', '2017-09-01 15:30:00']
7682
];
7783
}
7884
}

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
*/
66
namespace Magento\Framework\Stdlib\DateTime;
77

8-
use \Magento\Framework\Exception\LocalizedException;
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\App\ScopeInterface;
10+
use Magento\Framework\App\ScopeResolverInterface;
11+
use Magento\Framework\Exception\LocalizedException;
12+
use Magento\Framework\Locale\ResolverInterface;
913
use Magento\Framework\Phrase;
14+
use Magento\Framework\Stdlib\DateTime;
1015

1116
/**
1217
* Timezone library
18+
*
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1320
*/
1421
class Timezone implements TimezoneInterface
1522
{
@@ -29,12 +36,12 @@ class Timezone implements TimezoneInterface
2936
protected $_scopeType;
3037

3138
/**
32-
* @var \Magento\Framework\App\ScopeResolverInterface
39+
* @var ScopeResolverInterface
3340
*/
3441
protected $_scopeResolver;
3542

3643
/**
37-
* @var \Magento\Framework\Stdlib\DateTime
44+
* @var DateTime
3845
*/
3946
protected $_dateTime;
4047

@@ -44,28 +51,28 @@ class Timezone implements TimezoneInterface
4451
protected $_defaultTimezonePath;
4552

4653
/**
47-
* @var \Magento\Framework\App\Config\ScopeConfigInterface
54+
* @var ScopeConfigInterface
4855
*/
4956
protected $_scopeConfig;
5057

5158
/**
52-
* @var \Magento\Framework\Locale\ResolverInterface
59+
* @var ResolverInterface
5360
*/
5461
protected $_localeResolver;
5562

5663
/**
57-
* @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
58-
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
59-
* @param \Magento\Framework\Stdlib\DateTime $dateTime
60-
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
64+
* @param ScopeResolverInterface $scopeResolver
65+
* @param ResolverInterface $localeResolver
66+
* @param DateTime $dateTime
67+
* @param ScopeConfigInterface $scopeConfig
6168
* @param string $scopeType
6269
* @param string $defaultTimezonePath
6370
*/
6471
public function __construct(
65-
\Magento\Framework\App\ScopeResolverInterface $scopeResolver,
66-
\Magento\Framework\Locale\ResolverInterface $localeResolver,
67-
\Magento\Framework\Stdlib\DateTime $dateTime,
68-
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
72+
ScopeResolverInterface $scopeResolver,
73+
ResolverInterface $localeResolver,
74+
DateTime $dateTime,
75+
ScopeConfigInterface $scopeConfig,
6976
$scopeType,
7077
$defaultTimezonePath
7178
) {
@@ -174,6 +181,8 @@ public function date($date = null, $locale = null, $useTimezone = true, $include
174181
$timeType,
175182
new \DateTimeZone($timezone)
176183
);
184+
185+
$date = $this->appendTimeIfNeeded($date, $includeTime);
177186
$date = $formatter->parse($date) ?: (new \DateTime($date))->getTimestamp();
178187
break;
179188
}
@@ -226,7 +235,7 @@ public function scopeTimeStamp($scope = null)
226235
*/
227236
public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
228237
{
229-
if (!$scope instanceof \Magento\Framework\App\ScopeInterface) {
238+
if (!$scope instanceof ScopeInterface) {
230239
$scope = $this->_scopeResolver->getScope($scope);
231240
}
232241

@@ -318,4 +327,19 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s')
318327

319328
return $date->format($format);
320329
}
330+
331+
/**
332+
* Retrieve date with time
333+
*
334+
* @param string $date
335+
* @param bool $includeTime
336+
* @return string
337+
*/
338+
private function appendTimeIfNeeded($date, $includeTime)
339+
{
340+
if ($includeTime && !preg_match('/\d{1}:\d{2}/', $date)) {
341+
$date .= " 0:00am";
342+
}
343+
return $date;
344+
}
321345
}

0 commit comments

Comments
 (0)