开发者

Type conversion from IronPython.Modules.PythonDateTime to System.DateTime

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 开发者_如何学JAVAeither 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜