Hi, is it possible to convert ${!RUNTIME} value to HH:MM:SS format?
The answer:
{
"Command": "executeScript_Sandbox",
"Target": "return new Date(parseInt(${!runTime}) * 1000).toISOString().substr(11, 8)",
"Value": "hhmmss",
"Description": ""
},
{
"Command": "echo",
"Target": "${hhmmss}",
"Value": "",
"Description": ""
}
UPDATE: solution above works OK unless your macro runs more than 24h (hhmmss becomes 00:00:00 every 24h)
This one looks much better:
{ "Command": "executeScript_Sandbox", "Target": "return [3600, 60]\n .reduceRight(\n (p, b) => r => [Math.floor(r / b)].concat(p(r % b)),\n r => [r]\n )(parseInt(${!runTime}))\n .map(a => a.toString().padStart(2, '0'))\n .join(':');", "Value": "hhmmss", "Description": "" }, { "Command": "echo", "Target": "${hhmmss}", "Value": "", "Description": "" }
2 Likes