Initial TIME support in forcing
authorEdouard Tisserant
Thu, 31 Mar 2011 19:10:47 +0200
changeset 516 40290ddff19c
parent 515 55213a347f16
child 517 026ef159e8a2
Initial TIME support in forcing
dialogs/ForceVariableDialog.py
--- a/dialogs/ForceVariableDialog.py	Thu Mar 31 17:37:47 2011 +0200
+++ b/dialogs/ForceVariableDialog.py	Thu Mar 31 19:10:47 2011 +0200
@@ -22,6 +22,7 @@
 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import wx
+import datetime
 
 #-------------------------------------------------------------------------------
 #                            Force Variable Dialog
@@ -45,6 +46,13 @@
 getfloat = gen_get_function(float)
 getstring = gen_get_function(str)
 
+def gettime(v):
+    try:
+        return datetime.timedelta(0, float(v))
+    except: 
+        return None
+
+
 GetTypeValue = {"BOOL": lambda x: {"TRUE": True, "FALSE": False}.get(x.upper(), None),
                 "SINT": getinteger,
                 "INT": getinteger,
@@ -61,7 +69,8 @@
                 "REAL": getfloat,
                 "LREAL": getfloat,
                 "STRING": getstring,
-                "WSTRING": getstring}
+                "WSTRING": getstring,
+                "TIME": gettime}
 
 
 class ForceVariableDialog(wx.TextEntryDialog):