store-hours icon indicating copy to clipboard operation
store-hours copied to clipboard

Tomorrow

Open mrwijsman opened this issue 4 years ago • 1 comments

Description

So i'm not sure if i'm just blind or the function "tomorrow" isn't there.

I'd like to be able to call tomorrows opening times, I have a little status at the top of my website that shows whether the shop is open or closed at the moment. When the shop is open the status shows at what time the shop is closing and when the shop is closed i'd like to display the opening time for the next day (during weekdays shops opens at 6AM and in the weekends at 8 (saturday) and 9(sunday).

  {% if now > today.openCarwash and now < today.closeCarwash %}
  open until {{ today.closeCarwash|time('short', locale='nl') }}
  {% elseif now < today.openCarwash %}
  closed until {{ today.openCarwash|time('short', locale='nl') }}
  {% elseif now > today.closeCarwash %}
  closed until {{ tomorrow.openCarwash|time('short', locale='nl') }}
  {% endif %}

I hope it's not too much to ask for :)

mrwijsman avatar Apr 06 '21 23:04 mrwijsman

Allright so quick update, I have made a fix for my situation by adding the code below to the FieldData.php file and it works like a charm now :)

/**
     * Returns tomorrows’s hours.
     *
     * @return TomorrowData
     */
    public function getTomorrow(): DayData
    {
        $tomorrow = (int)(new \DateTime())->format('w');
        return $this[$tomorrow +1];
    }

mrwijsman avatar Apr 07 '21 19:04 mrwijsman