简体   繁体   English

InterShop日期比较条件不起作用

[英]InterShop dates comparison condition doesn't work

I have a condition which doesn't work: 我的状况不起作用:

<isif condition="#(Product:QLC_ValidTo > current_date)#">                        
    <span class="items-in-stock align-left">
        <isinclude template="product/inc/CC_StockStatus"/>
    </span>
</isif>

There are two valid values for both operands: 这两个操作数都有两个有效值:

Product:QLC_ValidTo = 29.11.16 and current_date = 13.10.17 产品:QLC_ValidTo = 29.11.16和current_date = 13.10.17

but it doesn't work. 但这不起作用。

I suppose is it incorrect to try to implement it as a simple comparison and values should be converted to another format? 我想尝试将其实现为简单的比较并将值转换为另一种格式是不正确的吗?

I don't agree with the following approach, see my previous post. 我不同意以下方法,请参阅我以前的文章。 If you insist on only isml then you can do the following. 如果仅坚持使用isml,则可以执行以下操作。

<%
    getPipelineDictionary().put("current_date",new Date());
%>
<isif condition="#(Product:QLC_ValidTo:getTime > current_date:getTime)#">                        
    <span class="items-in-stock align-left">
        <isinclude template="product/inc/CC_StockStatus"/>
    </span>
</isif>

Retrieve the milliseconds as a long and comparing it with gt operator. 检索毫秒长度并将其与gt运算符进行比较。 These operator only work with numbers. 这些运算符仅适用于数字。

Like it said before, rather do this in an extension. 就像之前说过的,宁愿扩展一下。 You can unit test it, deal with timezone issues, readability would improve etc. 您可以对其进行单元测试,处理时区问题,可读性会提高等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM