Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Convert seconds to hh:mm:ss in macro

I'd like to do this in a simple macro rather than resort to API. Here is my brute force version, it works but it is ugly and takes up a lot more space than it needs to. Someone with more math and coding knowledge than me might be able to make this very elegant. Can I convert the answer to hh:mm:ss? At ?{Kilometers Away} km away, a communication signal would require: [[round((?{Kilometers Away}/299792) * 100) / 100]] seconds, or [[round((?{Kilometers Away}/299792/60) * 100) / 100]] minutes, or [[round((?{Kilometers Away}/299792/3600) * 100) / 100]] hours
1708471730

Edited 1708471984
Joel
Pro
I feel like there is a way to work backwards, starting with how many whole hours it is (I presume using 'floor'), and figure out how many seconds are left over, then figure out how many whole minutes those remaining seconds represent, and figure out how many seconds are left, and then round those last remaining seconds. But whenever I try to assemble it, I somehow break it.
1708473568

Edited 1708473604
GiGs
Pro
Sheet Author
API Scripter
Here's a way to do it, but it's not pretty (and extends off the page): At ?{Kilometers Away} km away, a communication signal requires: [[{0,floor((?{Kilometers Away|0}/299792)/3600)}kh1]]:[[{0,floor((?{Kilometers Away}/299792)/60) - floor((?{Kilometers Away}/299792)/3600) * 60}kh1]]:[[{0,round((?{Kilometers Away}/299792) - floor((?{Kilometers Away}/299792)/60)*60)}kh1]] Entering numbers large enough for this to be meaningul is a pain, you might demand that people enter light seconds, or millions of kiliometers, which would change the calculation but make the entry much easier
Thank you thank you. Man, so annoying, all my math was right, but getting the parentheses and brackets was driving me NUTS. I'd get one working and break the other. The most I ever got working at once Hours and Minutes and for the life of me could not get it to do the easiest one, the seconds. lol Well, as I said, thanks a lot. Appreciate it.