6
6
namespace Magento \Cron \Model ;
7
7
8
8
use IntlDateFormatter ;
9
+ use Magento \Framework \Locale \ResolverInterface ;
9
10
use Magento \Framework \Stdlib \DateTime \DateTime ;
10
11
use \Magento \TestFramework \Helper \Bootstrap ;
11
12
@@ -76,8 +77,8 @@ public function testTryLockJobAlreadyLockedSucceeds()
76
77
->setJobCode ("test_job " )
77
78
->setStatus (Schedule::STATUS_RUNNING )
78
79
->setCreatedAt ($ this ->getTimeFormat ($ gmtTimestamp - $ offsetInThePast ))
79
- ->setScheduledAt ($ this ->getTimeFormat ($ gmtTimestamp - $ offsetInThePast + 60 , 'Y-M-d H:m ' ))
80
- ->setExecutedAt ($ this ->getTimeFormat ($ gmtTimestamp - $ offsetInThePast + 61 , 'Y-M-d H:m ' ));
80
+ ->setScheduledAt ($ this ->getTimeFormat ($ gmtTimestamp - $ offsetInThePast + 60 , 'Y-M-d HH:mm ' ))
81
+ ->setExecutedAt ($ this ->getTimeFormat ($ gmtTimestamp - $ offsetInThePast + 61 , 'Y-M-d HH:mm ' ));
81
82
$ oldSchedule ->save ();
82
83
83
84
$ schedule = $ this ->createSchedule ("test_job " , Schedule::STATUS_PENDING );
@@ -124,7 +125,7 @@ private function createSchedule($jobCode, $status, $timeOffset = 0)
124
125
->setJobCode ($ jobCode )
125
126
->setStatus ($ status )
126
127
->setCreatedAt ($ this ->getTimeFormat ($ gmtTimestamp ))
127
- ->setScheduledAt ($ this ->getTimeFormat ($ gmtTimestamp + $ timeOffset , 'Y-M-d H:m ' ));
128
+ ->setScheduledAt ($ this ->getTimeFormat ($ gmtTimestamp + $ timeOffset , 'Y-M-d HH:mm ' ));
128
129
$ schedule ->save ();
129
130
130
131
return $ schedule ;
@@ -138,11 +139,15 @@ private function createSchedule($jobCode, $status, $timeOffset = 0)
138
139
*
139
140
* @return string
140
141
*/
141
- private function getTimeFormat (int $ datetime , string $ format = 'Y-M-d H:m:s ' ): string
142
+ private function getTimeFormat (int $ datetime , string $ format = 'Y-M-d HH:mm:ss ' ): string
142
143
{
143
144
if (!$ this ->dateFormatter ) {
144
- $ locale = \Locale::getDefault ();
145
- $ this ->dateFormatter = new IntlDateFormatter ($ locale , IntlDateFormatter::SHORT , IntlDateFormatter::SHORT );
145
+ $ localeResolver = Bootstrap::getObjectManager ()->create (ResolverInterface::class);
146
+ $ this ->dateFormatter = new IntlDateFormatter (
147
+ $ localeResolver ->getLocale (),
148
+ IntlDateFormatter::SHORT ,
149
+ IntlDateFormatter::SHORT
150
+ );
146
151
}
147
152
$ this ->dateFormatter ->setPattern ($ format );
148
153
0 commit comments