Math operation (week number % 2)

Hello,

I need to do a simple math operation in a template. I need to know if the week number is even or odd.

{{(now().strftime(“%W”))}}

give me the week number, and it’s ok. But now I have to add the “% 2 == 0” but in every position I write it doesn’t work. Note that

{{(10 % 2) == 0}}

works. But I have to replace 10 with the now strftime %W

Any ideas? Thank you!

strftime returns a string, convert it to int.

{{ ((now().strftime("%W") | int) % 2) == 0 }}
3 Likes

Thank youuuuuuu!!!

Thank you @VDRainer!