1 Feb 12:14
now macro with dateFormat filter
Walter Krivanek, VividVisions <walter.krivanek <at> vividvisions.at>
2008-02-01 11:14:49 GMT
2008-02-01 11:14:49 GMT
Hi,
this combination of two core module features doesn't work:
<% now | dateFormat "yyyy" %>
Because dateFormat_filter just handles Date objects but now_macro
returns a string.
I've update my local copy of dateFormat_filter to create Date objects
if input is a string.
function dateFormat_filter(input, param, format) {
var format = param.format || format;
if (!input) {
return;
} else {
if (typeof input == "string") input = new Date(input);
return input.format(format);
}
}
Bye,
Walter
_______________________________________________ Helma-user mailing list Helma-user <at> helma.org http://helma.org/mailman/listinfo/helma-user(Continue reading)
Thanks!
Walter
Hannes Wallnoefer (01.02.2008 13:25):
> Hi Walter,
>
> 2008/2/1, Walter Krivanek, VividVisions <walter.krivanek <at> vividvisions.at
> >:
>
>> I've update my local copy of dateFormat_filter to create Date objects
>> if input is a string.
>
> Actually, you can pass a format string to now_macro:
>
> <% now format="yyyy" %>
>
> If do want the now macro with a filter chain, could just implement a
> macro that returns a raw date instead of a formatted string:
>
> function nowdate_macro() {
> return new Date();
> }
>
> <% nowdate | ... %>
RSS Feed