{{:assign now="now"|strtotime}} {{:assign today=$now|date:'Ymd'}} {{#foreach from=$config.closed item="slot"}} {{:assign start="%s %s, 00:00:00"|args:$slot.close_day:$slot.close_month|strtotime end="%s %s, 23:59:59"|args:$slot.reopen_day:$slot.reopen_month|strtotime }} {{if $end < $start}} {{:assign end="%s %s, 23:59:59, +1 year"|args:$slot.reopen_day:$slot.reopen_month|strtotime }} {{/if}} {{if $now >= $start && $now <= $end}}

Actuellement fermé jusqu'au {{$end|date_long}} inclus

{{:assign stop=1 closed=1}} {{:break}} {{/if}} {{/foreach}} {{if !$stop}} {{#foreach from=$config.open item="slot"}} {{if $slot.frequency != "this"}} {{:assign start="%s %s of this month, %s:00"|args:$slot.frequency:$slot.day:$slot.open|strtotime end="%s %s of this month, %s:00"|args:$slot.frequency:$slot.day:$slot.close|strtotime }} {{* Try next month *}} {{if $start < $now && $end < $now}} {{:assign start="%s %s of next month, %s:00"|args:$slot.frequency:$slot.day:$slot.open|strtotime end="%s %s of next month, %s:00"|args:$slot.frequency:$slot.day:$slot.close|strtotime }} {{/if}} {{else}} {{:assign start="%s %s, %s:00"|args:$slot.frequency:$slot.day:$slot.open|strtotime end="%s %s, %s:00"|args:$slot.frequency:$slot.day:$slot.close|strtotime }} {{* Try next week *}} {{if $end < $now}} {{:assign start="next %s, %s:00"|args:$slot.day:$slot.open|strtotime end="next %s, %s:00"|args:$slot.day:$slot.close|strtotime }} {{/if}} {{/if}} {{if $now >= $start && $now <= $end}}

Ouvert aujourd'hui jusqu'à {{$slot.close}}

{{:assign stop=1}} {{:break}} {{elseif $end < $now}} {{:continue}} {{/if}} {{:assign diff="%d-%d"|math:$now:$start}} {{if $diff > $closest}} {{:assign closest=$diff closest_slot=$slot closest_date=$start}} {{/if}} {{/foreach}} {{/if}} {{if !$stop && $closest}} {{if $closest_date|date:'Ymd' == $now|date:'Ymd'}}

Prochaine ouverture : aujourd'hui à {{$closest_slot.open}}

{{elseif $closest_date|date:'Ymd' == "tomorrow"|strtotime|date:'Ymd'}}

Prochaine ouverture : demain à {{$closest_slot.open}}

{{else}}

Prochaine ouverture : le {{$closest_date|strftime:"%A %e %B"}} à {{$closest_slot.open}}

{{/if}} {{/if}}