How to create an exception using datetime with seconds
vipera7 opened this issue · comments
Hi,
I noticed in the documentation that it's possible to create intervals for exceptions, but I'm wondering how I can use datetime instead of just a date.
According to the documentation:
'exceptions' => [
// Only happening in 2024
'2024-06-25 to 2024-07-01' => [
'hours' => [],
'data' => 'Closed for works',
],
I would like to achieve something like this, where datetime is specified:
'exceptions' => [
// Only happening in 2024
'2024-06-25 21:36:15 to 2024-07-01 18:14:28' => [
'hours' => [],
'data' => 'Closed for works',
],
Hello,
This package split the time in days dans days contain ranges of Time
, as you can see in the code, Time
only contain $hours
and $minute
granularity to represent it: https://github.com/spatie/opening-hours/blob/master/src/Time.php#L18-L20
Then range of days is not an actual component, it's just a short cut syntax that will repeat the content into each day.
A range such as '2024-06-25 21:36 to 2024-07-01 18:14
can be described like this:
'exceptions' => [
// Only happening in 2024
'2024-06-25' => [
'hours' => ['00:00-21:36'],
'data' => 'Closed for works',
],
'2024-06-26 to 2024-06-30' => [
'hours' => [],
'data' => 'Closed for works',
],
'2024-07-01' => [
'hours' => ['18:14-24:00'],
'data' => 'Closed for works',
],
That's all the library supports at the moment, seconds and microseconds are handled, it would need a significant refactor.
Dear contributor,
because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.