Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
|
That will do it, thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I am making a custom-api widget that utilizes Unraid's now native API (available from v7.2.0+) to display some server stats and I am a bit stuck on finding a way to calculate the server's current uptime. The API provides
data.info.os.uptimeDT representing when the server was last booted up, anddata.info.timeas the current server's time. Below is the example of the JSON response from the API with example DTs.So naturally, in my custom-api widget template i parsed those strings;
which parses them seemingly fine as I can print the DTs successfully in the widget, but after that i realized i cannot use the glance's
sub(a, b float)function on DTs to get thetime.Durationdiff because thesubaccepts only float. I therefore tried converting the DTs to unix timestamp using:and while
timeDT_unixanduptimeDT_unixprint as valid unix timestamps, thediffalways prints asNaN. I also realized that even if I got thediffas unix timestamp, i might not be able to convert it totime.Durationas I currently don't see relevant functions for it in custom-api Functions docs.My goal is to format the difference of the DTs into something human readable, like
2 days, 3 hours, 34 minutes. Am I missing some obvious way to achieve what I want or is Glance lacking the relevant DT functions? I don't mind trying to implement them and make a PR, but i wanted to ask first in case I am not seeing something obvious due to my limited knowledge of Go lang or the expressions syntax which is very well possible since I am working with/learning this all just for Glance.Beta Was this translation helpful? Give feedback.
All reactions