Skip to content

Commit 0b9fbb7

Browse files
committed
#36947 Added timezone parsing to creditmemo, invoice, shipment comments dates
1 parent 4746e94 commit 0b9fbb7

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

app/code/Magento/SalesGraphQl/Model/Resolver/CreditMemo/CreditMemoComments.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,27 @@
77

88
namespace Magento\SalesGraphQl\Model\Resolver\CreditMemo;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Query\ResolverInterface;
1314
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1416
use Magento\Sales\Api\Data\CreditmemoInterface;
1517

1618
/**
1719
* Resolve credit memo comments
1820
*/
1921
class CreditMemoComments implements ResolverInterface
2022
{
23+
private TimezoneInterface $timezone;
24+
25+
public function __construct(
26+
TimezoneInterface $timezone = null
27+
) {
28+
$this->timezone = $timezone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
29+
}
30+
2131
/**
2232
* @inheritDoc
2333
*/
@@ -40,7 +50,7 @@ public function resolve(
4050
if ($comment->getIsVisibleOnFront()) {
4151
$comments[] = [
4252
'message' => $comment->getComment(),
43-
'timestamp' => $comment->getCreatedAt()
53+
'timestamp' => $this->timezone->date($comment->getCreatedAt())
4454
];
4555
}
4656
}

app/code/Magento/SalesGraphQl/Model/Resolver/Invoices.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace Magento\SalesGraphQl\Model\Resolver;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Query\ResolverInterface;
1314
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1416
use Magento\Sales\Api\Data\OrderInterface;
1517
use Magento\Sales\Api\Data\InvoiceInterface;
1618

@@ -19,6 +21,14 @@
1921
*/
2022
class Invoices implements ResolverInterface
2123
{
24+
private TimezoneInterface $timezone;
25+
26+
public function __construct(
27+
TimezoneInterface $timezone = null
28+
) {
29+
$this->timezone = $timezone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
30+
}
31+
2232
/**
2333
* @inheritDoc
2434
*/
@@ -61,7 +71,7 @@ private function getInvoiceComments(InvoiceInterface $invoice): array
6171
foreach ($invoice->getComments() as $comment) {
6272
if ($comment->getIsVisibleOnFront()) {
6373
$comments[] = [
64-
'timestamp' => $comment->getCreatedAt(),
74+
'timestamp' => $this->timezone->date($comment->getCreatedAt()),
6575
'message' => $comment->getComment()
6676
];
6777
}

app/code/Magento/SalesGraphQl/Model/Resolver/Shipments.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77

88
namespace Magento\SalesGraphQl\Model\Resolver;
99

10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\GraphQl\Config\Element\Field;
1213
use Magento\Framework\GraphQl\Query\ResolverInterface;
1314
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
15+
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
1416
use Magento\Sales\Api\Data\ShipmentInterface;
1517
use Magento\Sales\Model\Order;
1618

@@ -19,6 +21,14 @@
1921
*/
2022
class Shipments implements ResolverInterface
2123
{
24+
private TimezoneInterface $timezone;
25+
26+
public function __construct(
27+
TimezoneInterface $timezone = null
28+
) {
29+
$this->timezone = $timezone ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
30+
}
31+
2232
/**
2333
* @inheritDoc
2434
*/
@@ -62,7 +72,7 @@ private function getShipmentComments(ShipmentInterface $shipment): array
6272
foreach ($shipment->getComments() as $comment) {
6373
if ($comment->getIsVisibleOnFront()) {
6474
$comments[] = [
65-
'timestamp' => $comment->getCreatedAt(),
75+
'timestamp' => $this->timezone->date($comment->getCreatedAt()),
6676
'message' => $comment->getComment()
6777
];
6878
}

0 commit comments

Comments
 (0)