Countdown timer

Is it possible to create a countdown timer? For example countdown days until Christmas.

1 Like

You won’t get Christmas exactly, since depending on whether it is a leap year or not the day changes. For a non leap year it day 358/365, in a leap year it’s 359/365.

Now lets assume its not a leap year then you can simply do:

$358-#DD#>=0?358-#DD#:365-#DD#+358$

What happens here is;

If 358 - the current day of the year is bigger than 0, it means that Christmas is still ahead. Getting Christmas day would be 358 - the current day of the year.

If Christmas has already passed, we get the remained of the year (365-#DD#) and add the amount of days until christmas.

1 Like

I’m a huge math geek so I’ll expand the answer provided by @tim_littlelabs for @mwengel62 to account for leap years. First the long answer and then the explanation. Yes, I did test this using the time travel feature in creator.

$(#Dy#/4)==floor(#Dy#/4)&&#DD#<=360?360-#DD#:$$(#Dy#/4)!=floor(#Dy#/4)&&#DD#<=359?359-#DD#:$$((#Dy#+1)/4)==floor((#Dy#+1)/4)?365-#DD#+360:$$(#Dy#/4)==floor(#Dy#/4)?366-#DD#+359:365-#DD#+359$

A lot of conditionals here, but I’m breaking this up into 5 if statements in this order:

This year is a leap year and it is before or on Christmas
Else this year is NOT a leap year and it is before or on Christmas
(now we know it is after Christmas so the if gets simpler)
Else next year is a leap year (and it is after Christmas)
Else this year is a leap year (and it is after Christmas)
Else neither this year not next year is a leap year (and it is after Christmas)

Now…one pedantic side note. This assumes every year that is divisible by 4 is a leap year. This is not true (if it is evenly divisible by 100, but not by 400 then it is not a leap year…so 2000 is a leap year…2100 is not). I have not accounted for that so the calculations in 2100 will be off by a day. If you want that math, offer me some money and I’ll figure that out as well :smile:

Other pedantic note. I slightly disagree on the day of the year that Christmas is I did test my assumptions and they appear to work correctly.

5 Likes

That is amazing @CompuChip. Awesome work! It’s really great to see people helping each other out like this. Keep up the good work! It’s appreciated!

1 Like

I tried this on mine and I get the following displayed on my watch:
360-300360-300+359
But Facer creator interface displays correctly at 60. Apparently my watch (LG Urbane) doesn’t like multiple statements. I might try to break this up into multiple layers and see what happens.

Modified the statement to take out the double $$ and I’m now down to “360-300”.

Modified again to add parenthesis around the math functions and it is now working correctly.

Yeah, those parenthesis are a pain and the evaluation of them seem to change depending on the time of day.

Good code, works great on Gear S3 Frontier, thanks!

Here is my HALLOWEEN countdown.

$(#Dy#/4)==floor(#Dy#/4)&&#DD#<=305?305-#DD#:$$(#Dy#/4)!=floor(#Dy#/4)&&#DD#<=304?304-#DD#:$$((#Dy#+1)/4)==floor((#Dy#+1)/4)?365-#DD#+304:$$(#Dy#/4)==floor(#Dy#/4)?366-#DD#+304:365-#DD#+304$ till Halloween

Can you give the exact string to make it work on Urbane? Sending my S3 Frontier back and want this face to work on my Urbane.

Hey i tried to use the string and it works fine in the editor but when i transfer it to my watch, it just shows the string and not the result.

my watch is a sony smart watch 3… doesn’t it support it, do i need AW 2.0 or what i’m i missing?

thx

1 Like

Would it be possible to post the working formulas for countdown in the “Recipes” tutorial?

1 Like

Did you ever reslove this issue? I have the same problem with Ticwatch E???

…or anyone figure out way to have the number appear as it does on the online interface? the watch shows the string. I have a Tic Watch E.

I think it’s certain watches… mine works fine in the editor, but my watch (LG Sport) says 0 days.

It may be a recent change, not sure.

1 Like

Thank you so much! This saves a lot of time on research and brain power for someone who is NOT mathematically inclined.

Hey folks, came here for the countdown timer maths. This is super helpful! I’m learning :slight_smile:

I’m hoping to calculate the time difference of the current date vs goal date with years, weeks, and days.

it would be formatted as such: 00:46:03

lmk if someone already figured this one out! This would be insanely useful.

There is no inspection more on this to see where you put the code

Can someone please add the code for BEFORE thanksgiving counter and one for after?

I tried and all I get is a number of 345. HELP

The date for Thanksgiving changes each year so you would have to keep your code updated each year.
Refer to this and replace the Christmas Day number with whatever day number Thanksgiving is.

An online search can provide you with a calendar chart showing the day of the year numbers.

1 Like

Thanks for the help

You’re welcome. :slightly_smiling_face: