Coming over from Zooper, which I knew really well. KWGT Pro is so much better than Zooper, and I'm really having fun using it.
I'm trying to display the time until the next alarm as h:mm, but I can't figure out what math to use to get that. I am currently using $df(si(alarmd)) which works fine, but isn't exactly what I want.
What I'd really like is: If it's more than one day until the next alarm, display in a text field: "'d' days and 'h' hours until next alarm", otherwise, display "(h:mm)".
I know this is probably pretty basic, but I'd appreciate a hand (no time-pun intended).
So, if you need to measure time to an even (any date event) you can use TF function (TF: Format a time span (es "3 hours ago")), for example, you can do $tf(si(alarmd))$ for the "automatic" mode or use $tf(si(alarmd), "D' days 'h' hours and 'm' minutes'")$ to display details (i am using single hypens ' to escape normal text inside a date formula, this is valid also in DF, this is to avoid writing "$tf(si(alarmd), D)$ days $tf(si(alarmd), h)$ hours and $tf(si(alarmd), m)$ minutes"
TF() is pretty smart, so if you pass a date then it will print time relative to now (so "in 10 hours" or "10 hours ago") while if you pass a number of seconds it will just parse absolute time (es "10 hours"). Let me give some example:
Time to / from a date $tf(si(alarmd))$ will write like "in 5 hours"
Delta between 2 dates so $tf(ai(nsunrise) - ai(sunset))$ will parse the time between "next sunrise" and "today sunset" and write something like "8 hours" which is the duration of the "night" today
in case anyone is interested, here's the solution I came up with. I'm sure it could be shortened a bit, but it should be quite clear what is going on.
What I wanted was for the alarm text field to display, for example: "Next alarm - 2d 4h" if the alarm is more than a day away. If the alarm is less than a day away, but more than an hour away, I wanted "Next alarm - xh:ym". And, if the alarm is less than an hour away, I wanted "Next Alarm - xm"