【发布时间】:2017-04-27 13:10:33
【问题描述】:
我已经给出了两次(教义类型时间)并想检查当前时间是否在 for-if 循环中的这些时间之间。我使用来自树枝的Date compare。我的代码如下所示:
{% for time in restaurant.openingHours if ((time.day == day) and (date(time.opening) <= date()) and (date(time.closing) >= date())) %}
<span class="restaurant_info green"></span>
{% else %}
<span class="restaurant_info red"></span>
{% endfor %}
最后一个条件(date(time.closing) >= date()) 为假,但关闭为真。有人想解决这个问题吗?
【问题讨论】:
-
你有错误吗??
-
请贴出time.opening和time.closing的内容以及你当前的date()。