VoxCommando
General Discussion => General Discussion => Topic started by: mht on April 29, 2015, 05:13:17 PM
-
I have a timstamp (date and time) in this format: 1430337630
How do I convert this timestamp to a readable time string?
-
You can use the Python plugin. Simplest would be something like:
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="667" name="convert time stamp" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>result = time.ctime(1430337630)</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>The time is {LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>convert time stamp</phrase>
</command>
https://docs.python.org/2/library/time.html
-
Tank you!
I follow your example. It didnt work at first. I found out that I had to add time library first.
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.6-->
<command id="667" name="convert time stamp" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>import time; result= time.ctime(1430337630)</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>The time is {LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>convert time stamp</phrase>
</command>
-
Sorry! Yes that was my oversight. I already had the time library loaded previously, so it worked for me.
I'm glad that you could solve the problem.