Expression help

Hello,

I’m trying to come up with an expression to figure out how many days are left until the 12th of either this or next month, came up with this:

$ #Dd# < 12 ? (12-#Dd#) : ((#DIM#-#Dd#)+12) $

Suppose today is 5th. Is today’s number less than 12?

yes
show result of 12 minus today’s number, 12 - 5 = 7 days left

or suppose it’s 15th.

no
Is it equal or bigger than 12. Get the maximum number of days this month (suppose 30), subtract today in order to get how many days are left (30 - 15 = 15 days to end of month), add 12 to the end of that result to get the total days left (15 + 12 = 27 days left until next 12th).

Math aside, there must be a problem in my formatting, everything breaks as soon as I add in the closing “$”… i.e. blank text.

LE:
Tried re-writing the expression, and this time it works, surprisingly. Copy pasting:

$#Dd#<12?(12-#Dd#):((#DIM#-#Dd#)+12)$

Somehow it works now, even though it’s the exact same thing.
Weird, case closed.

Case not quite closed for me, I’m afraid. There seems to be a general problem with conditionals.

My idea was to have a colon blink once a second. If the #Ds# is even, show the colon; if odd, don’t show the colon. This was my first attempt:

$#Ds#%2==0?100:0$

This worked fine in the creator, but when I sent it to the watch, the colon was permanently invisible. To try to get a handle on what was going on, I added a new text element and set the text to the following:

#Ds# (#Ds#%2)

but this displayed only the #Ds# property and nothing else, even in the creator. I consulted the wiki, and the modulus operator isn’t documented there. So I tried this instead:

#Ds# ($floor(#Ds#/2)==(#Ds#/2)?0:1$)

and again, it displayed the seconds just fine, but not the result of the conditional.

There does seem to be something really funky going on here, and OP’s experience suggests it’s intermittent. I’ve tried all sorts of combinations of parentheses, and nothing seems to work for me.

Chew on this then:

Correct result in Creator & Preview, versus final result on the watch itself.

Ugh.

You expect to encounter a few bugs after a major update, but these are pretty serious issues that should have been caught long before launch. Looks like the contents of the expression are being interpreted by the app on the watch as a string literal instead of being evaluated.

Well hey, I can at least practice basic arithmetic while they sort it. It may be an issue with nested expressions, never seen any issues with simple ones.