store-hours
store-hours copied to clipboard
Timeslots all returning today as date
Description
While working on getting the new getGroupedRanges()
feature preparsed so i can use it via GraphQL I saw that all dates returned by the plugin are using today as the date.
For example given this template:
{% apply spaceless %}
{{element.openingHours.getGroupedRanges(1) | json_encode}}
{% endapply %}
i get the following result:
[
[
{
"open": {
"date": "2024-08-08 07:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 19:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
{
"open": {
"date": "2024-08-08 07:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 19:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
{
"open": {
"date": "2024-08-08 07:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 19:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
{
"open": {
"date": "2024-08-08 07:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 19:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
}
],
[
{
"open": {
"date": "2024-08-08 07:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 21:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
}
],
[
{
"open": {
"date": "2024-08-08 08:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 22:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
},
{
"open": {
"date": "2024-08-08 08:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"close": {
"date": "2024-08-08 22:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
}
]
]
while the groups are all correct, there is no way to see which day of the weeks the timeslots are refering to.
I tested this via GraphQL as well:
{
locationsEntries {
... on location_Entry {
openingHours {
open
close
}
}
}
}
results in:
{
"data": {
"locationsEntries": [
{
"openingHours": [
{
"open": "2024-08-08T08:00:00+02:00",
"close": "2024-08-08T22:00:00+02:00"
},
{
"open": "2024-08-08T07:00:00+02:00",
"close": "2024-08-08T19:00:00+02:00"
},
{
"open": "2024-08-08T07:00:00+02:00",
"close": "2024-08-08T19:00:00+02:00"
},
{
"open": "2024-08-08T07:00:00+02:00",
"close": "2024-08-08T19:00:00+02:00"
},
{
"open": "2024-08-08T07:00:00+02:00",
"close": "2024-08-08T19:00:00+02:00"
},
{
"open": "2024-08-08T07:00:00+02:00",
"close": "2024-08-08T21:00:00+02:00"
},
{
"open": "2024-08-08T08:00:00+02:00",
"close": "2024-08-08T22:00:00+02:00"
}
]
}
]
}
}
Is there no way to get the "day of the week" as an int in the same result without having to call the getMon()
/getTue()
functions?
Additional info
- Craft version: 5.2.10
- Plugins & versions: 4.2.0