views:

50

answers:

1

I'm hosting an IronPython engine instance in my C# (Silverlight 4) app to execute some Python scripts on the fly. These scripts can return values of either IronPython.Modules.PythonDateTime+datetime, IronPython.Modules.PythonDateTime+date or IronPython.Modules.PythonDateTime+time types. I need to convert these to System.DateTime values in C# without losing resolution. How do I do this?

+1  A: 

I don't think there's a good way to do this other than pulling the elements of the date time out from properties like year, month, day, etc... and constructing a new DateTime instance from those. You could file feature request on ironpython.codeplex.com to have an explicit conversion to DateTime. That's pretty trivial to implement for at least some of these because they're using a DateTime behind the scenes.

Dino Viehland
Thanks, Dino. That's what I'm doing right now, but I'm not sure if that will result in a loss of resolution. Some kind of direct conversion using ticks or an equivalent property would have been great...
Schemer