I'm trying to put together a basic countdown widget, I've put this together fine, my problem occurs when displaying the minutes remaining. I have a Global Variable "datemins" for the minutes (will explain this later), with the following format $tf(2023y12M25d09h00m,mm)$ in the preview pane this displays the correct number of minutes, ie 33,08 etc (note the leading zero)
Now on the text box of the widget I have the formula $if(gv(date)<1, gv(datehour)+ ":"+tc(lpad, gv(datemins), 2, 0), gv(date))$ This will only show the hours (one global variable) and minutes (the other mentioned earlier) remaining if there is less than one day until the event, otherwise it just shows the number of days ("date" variable), this works fine until the number of minutes is less than ten then instead of displaying 3:08 it displays 3:8, now I know there is no issue with the tc(lpad, gv(datemins), 2, 0) part as I've put this outside of the if statement and it displays 3:08
It seems that somehow the 08 being in the if statement results in what is displayed having the leading zeros ripped off. This isn't also caused by the "Text Converter" method as this was something I tried later when trying to fix the problem, just calling the variable " gv(datemins) " still results in the leading zero being ripped off. Currently the only work around I have found is to pad the front of the variable with the letter O (I can't use a zero as this gets ripped off too. This is what I currently have
$if(gv(date)<1, gv(datehour)+ ":"+if(gv(datemins)<10, "O"+gv(datemins), gv(datemins)), gv(date))$
Whilst for the most part this is fine, it is noticeable and more so when there are no minutes ie 00, as this will be displayed O0 it's also noteworthy that the trailing zero isn't ripped off.
So, my question is... is this an issue as the display problem only occurs within an if statement, (it might occur in other statements ie while but I haven't tried this) and if not, can anyone suggest something so that I can get it to display correctly. Whilst I am the only one who is likely to see this widget it's still something that irks me, and might be something that someone in the community would wish to know for future.
Thanks for any help