-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetUptime
21 lines (21 loc) · 1.21 KB
/
getUptime
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
:global UpTime
:local intGoff [:tonum [/system clock get gmt-offset]]
:if ($intGoff > 93600) do={:set intGoff ((4294967296 - $intGoff) * -1)}
:local epochNow (([/tool fetch url="https://api.kangarie.com/time/str/now" as-value output=user])->"data")
:local upTime [/system resource get uptime]
:local wPos [:find $upTime "w" -1]
:local dPos [:find $upTime "d" -1]
:local utLen [:len $upTime]
:local utSec [:pick $upTime ($utLen - 2) $utLen]
:local utMin [:pick $upTime ($utLen - 5) ($utLen - 3)]
:local utHou [:pick $upTime ($utLen - 8) ($utLen - 6)]
:local utDay 0
:local utWee 0
:if (([:typeof $wPos] = "nil") and ([:typeof $dPos] = "num")) do={:set utDay [:pick $upTime 0 $dPos] }
:if (([:typeof $wPos] = "num") and ([:typeof $dPos] = "num")) do={:set utDay [:pick $upTime ($wPos + 1) $dPos] }
:if ([:typeof $wPos] = "num") do={:set utWee [:pick $upTime 0 $wPos] }
:local totUtSec ($utSec + (60 * $utMin) + (60 * 60 * $utHou) + (60 * 60 * 24 * $utDay) + (60 * 60 * 24 * 7 * $utWee))
:local epochStart ($epochNow - $totUtSec + $intGoff)
:local datetimeStart (([/tool fetch url="https://api.kangarie.com/time/str/$epochStart" as-value output=user])->"data")
:set UpTime $datetimeStart
# :put "RouterBOARD is started $datetimeStart"