Skip to content

Commit 281cf7d

Browse files
committed
Properly set first day of week
1 parent 9854ae6 commit 281cf7d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ViewModel/Options.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33

44
namespace Loki\Flatpickr\ViewModel;
55

6+
use Magento\Framework\App\Config\ScopeConfigInterface;
67
use Magento\Framework\View\Element\AbstractBlock;
78
use Magento\Framework\View\Element\Block\ArgumentInterface;
9+
use Magento\Store\Model\ScopeInterface;
810

911
class Options implements ArgumentInterface
1012
{
13+
public function __construct(
14+
private ScopeConfigInterface $scopeConfig
15+
) {
16+
}
17+
1118
public function toJson(AbstractBlock $block): string
1219
{
1320
$options = array_merge($this->getDefaultOptions(), (array)$block->getOptions());
@@ -21,6 +28,17 @@ public function getDefaultOptions(): array
2128
'altInput' => true,
2229
'altFormat' => 'Y-m-d',
2330
'dateFormat' => 'Y-m-d',
31+
'locale' => [
32+
'firstDayOfWeek' => $this->getFirstDayOfWeek(),
33+
]
2434
];
2535
}
36+
37+
private function getFirstDayOfWeek(): int
38+
{
39+
return (int)$this->scopeConfig->getValue(
40+
'general/locale/firstday',
41+
ScopeInterface::SCOPE_STORE
42+
);
43+
}
2644
}

0 commit comments

Comments
 (0)