Sorry if it's a double post but I don't get if the first was sent
correctly or not...
Hi all,
the topic was already discussed a few times but it seems I'm missing
something... It seems that dates stored in nodes are not wrapped
correctly in the calendar model.
What I need to do is a simple comparison of a node date to the current
date, just like this:
[@cms.setNode var="myNode" contentNode=queryResult[0] /]
[#assign result=.now gt myNode.myDate /]
where myNode is obviously a wrapped content, and myDate is a Jackrabbit
Date node data (Calendar).
The above line fails, with this error:
Java backtrace for programmers:
----------
freemarker.template.TemplateException: The only legal comparisons are
between two numbers, two strings, or two dates.
Left hand operand is a freemarker.template.SimpleDate
Right hand operand is a freemarker.template.SimpleScalar
Looking into the code, myDate seems to be put in the wrapped map as a
String and not as a Calendar object, so when it's extracted from the
content it is not wrapped by CalendarModel.
Is this the desider behaviour? This way the comparison between dates can
be done only through string representation, even if they are formatted
in iso. This is ok for most comparison, but it will lose some subtleties
of time zones and daylight saving times...
But if this is the case, then when the CalendarModel class is used?
Anyway, for now my options are to use either the reparsed date like this:
[#assign result=.now gt
myNode.myDate?datetime("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") /]
or converting now in a string and use string comparison, but I haven't
found a string comparator in freemarker ("gt" doesn't work).
Regards, Danilo.
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------