Jan 21, 2021 12:16 PM - edited Jan 21, 2021 12:19 PM
Hello,
I am comparing formated date times from HubDB to add specific class names for sorting purposes. The following code is the comparison piece. Also of note the following code IS within the forloop that gets the values from the database.
{% set isthisweek = row.end_date|datetimeformat('%U') %}
{% set isthismonth = row.end_date|datetimeformat('%m') %}
{% set isthreemonths = row.end_date|plus_time(2, 'months') %}
{% set thisweek = local_dt|datetimeformat('%U') %}
{% set thismonth = local_dt|datetimeformat('%m') %}
{% set thisthree = local_dt|plus_time(2, 'months') %}
{% if isthisweek == thisweek %}
{% set mydate = 'this-week this-month three-months' %}
{% elif (isthismonth == thismonth) != false %}
{% set mydate = 'this-month three-months' %}
{% elif thisthree|between_times(isthreemonths, 'months') > 0 and thisthree|between_times(isthreemonths, 'months') <= 2 %}
{% set mydate = 'three-months' %}
{% elif thisthree|between_times(isthreemonths, 'months') > 2 %}
{% set mydate = 'more-than-three' %}
{% endif %}
My problem is that comparing the variables isthisweek to thisweek is not making logical sense. For example I have a class set for "this-week" if the two are equal. When using this however I have "card" with a week value of 04 (which is this week 01/21/2021[eg today]) and another for 02/09/2021 which is week 07. The February event is getting the class this-week for some reason I cannot fathom.
I have also tried the following comparison operation:
//Original
{% if isthisweek == thisweek %}
{% set mydate = 'this-week this-month three-months' %}
//Also Tried
{% if (isthisweek - thisweek) == 0 %}
{% set mydate = 'this-week this-month three-months' %}
{% if (isthisweek|int - thisweek|int) == 0|int %}
{% set mydate = 'this-week this-month three-months' %}
{% if isthisweek|int == thisweek|int %}
{% set mydate = 'this-week this-month three-months' %}
None of these seem to work. If anyone has anythoughts on this I would like to hear them as I am currently stuck.
Thanks in advance.
Jan 24, 2021 10:47 PM
Hi @narmstrong ! Thank you for posting your question:)
@amwilie and @Kevin-C , is this topic something you guys are familiar with? Would you mind sharing your advice for @narmstrong ?
Jan 25, 2021 10:03 AM
Hey @narmstrong
I was unable to recreate this error. Is this issue still happening?
If so, maybe you're declaring the "mydate" somewhere else and have the scope confused?