hybridelabs / fluent-opening-hours
营业时间格式化工具
1.1.2
2020-03-25 13:48 UTC
Requires
- php: ^7.4
Requires (Dev)
- ext-json: *
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^3.0@dev
This package is auto-updated.
Last update: 2024-09-26 00:09:45 UTC
README
以流畅的方式格式化营业时间
$openingHours = [
0 => ['10:30-12:00'],
1 => [],
2 => ['9:00-11:30'],
3 => ['8:00-10:00', '14:00-18:00'],
4 => [],
5 => [],
6 => [],
];
$fluentOpeningHours = (new FluentOpeningHours)->parse($openingHours);
echo $fluentOpeningHours->format();
结果为
monday from 10:30 to 12:00, wednesday from 9:00 to 11:30, thursday from 8:00 to 10:00 and from 14:00 to 18:00, tuesday, friday, saturday and sunday closed
方法
在格式化输出之前,可以通过调用 $fluentOpeningHours->openOnly()
来省略关闭的天数。
选项
可以通过提供带有新值的选项对象并将其传递给 FluentOpeningHours 类来替换所有字符串
$options = [
'from' => 'de',
'to' => 'à',
'and' => 'et',
'closed' => 'fermé',
'days' => ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'],
];
这将结果更改为
lundi de 10:30 à 12:00, mercredi de 9:00 à 11:30, jeudi de 8:00 à 10:00 et de 14:00 à 18:00, mardi, vendredi, samedi et dimanche fermé