Hi there, I have an expression set up to calculate Swatch Internet Time, which is only ever 3 digits long. The expression is created in a way however that would end up 4 digits long in some cases, and I just need a way to only keep the last three digits of the result. How can this be achieved? For example:
Original Output:
1075
Desired Output:
075
Could you use ( ( expression ) %1000 ) ?
This should limit the output to between 0 and 999.
That is a great idea! Gave that a shot and it does technically work, the only issue is that it unfortunately doesn’t keep the leading zeroes, which I would need in this situation. Any way to ensure that leading zeroes are kept? I could do so with conditionals, but since nested conditionals aren’t supported I wouldn’t be able to do so for both single and double digit instances.
My current solution is just to place a shape layer over the first digit that matches the color of the background, but this of course only works for single color backgrounds.
Could you post whatever formula you’ve got going on at the moment? the one where you’d need the nested conditionals to keep the zeros? It should make it easier for anyone to drop by and try to give you a hand
But of course! Here’s my current implementation. The one side effect of this one is that because I am adding 1 to the time (to make it Biel Mean Time), the number exceeds 1000 for an hour, which isn’t technically possible in Swatch Internet Time, and is why I need to exclude the first digit. In this case, a single digit never comes up, so I just have a conditonal for cases where a number less than 100 appears, and just add a single 0 before the formula in this case:
$(floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))<100?0(floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4)):(floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))$
So for example, if the current time is 18:53 EST, the output is 1037 and the ‘else’ portion of the conditional is used. But at 19:27 EST, the output is 60, so the ‘then’ portion of the conditional is used to add the 0.
What would be ideal is if I could use the modulo idea that mikeoday had, in a nested conditional like this:
$((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)<100?$((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)<10?00((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000):0((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)$:((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)$
So that if the result is less than 100, another conditional will run to check if the result is also less than 10.
Having ‘else if’ would be even better than a nested conditional, but I don’t think I saw anywhere that that was an option.
Well, I’m still not 100% sure if the following rather undocumented conditional method is okay to use, or when… but I think it’s okay to use in text fields which I think is where you’re using all of this on?
$ condition ? true : $$ else Condition ? true : else $
I don’t wanna take a stab at converting your formula for fear I’ll mess a digit somewhere but hopefully that’s clear enough o/ (just don’t add the spaces I added, those are just for extra clarification).
Edit:
You can also use &&
and ||
(and, or respectively), in case you didn’t know.
1 Like
Good gravy you are an absolute madman! THAT WORKED! This opens up so many more possibilities for me now on another watch project I am working on so THANK YOU! Both of you have been a great help!
In case anyone else out there is insane and wants to use Swatch Internet Time, here is my final expression:
$((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)<10?00((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000):$$((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)<100?0((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000):((floor(((#DUH#+1)*3600+#Dm#*60+#Ds#)/86.4))%1000)$
3 Likes