Created
June 12, 2018 16:49
-
-
Save eliphaslevy/8ce01e572c401d37fad55d9090303730 to your computer and use it in GitHub Desktop.
Mikrotik Time to Seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:global timeToSeconds do={ | |
:local iSeconds 0; :local upTxt $1; :local daypos 0; | |
:for pos from=0 to=([:len $upTxt] - 8) do={ | |
:if ([:pick $upTxt $pos] = "w") do={ | |
:set iSeconds ( [:pick $upTxt 0 ($pos)] * 7 * 24 * 60 * 60 ); | |
:set daypos ($pos+1); | |
} | |
:if ([:pick $upTxt $pos] = "d") do={ | |
:set iSeconds ( $iSeconds + ([:pick $upTxt ($daypos) ($pos)] * 24 * 60 * 60) ); | |
} | |
} | |
:set iSeconds ( $iSeconds + ([:pick $upTxt ([:len $upTxt]-8) ([:len $upTxt]-6)] * 60 * 60) ); | |
:set iSeconds ( $iSeconds + ([:pick $upTxt ([:len $upTxt]-5) ([:len $upTxt]-3)] * 60) ); | |
:return $iSeconds; | |
} | |
:put [$timeToSeconds "1w3d10:51:24"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment