将zope DateTime对象转换为Python DateTime对象的最佳方法是什么?

将zope DateTime对象转换为Python DateTime对象的最佳方法是什么?,python,zope,Python,Zope,我需要将Zope2DateTime对象转换为Python DateTime对象。最好的方法是什么?谢谢你,埃里卡,如果你是说 那么反过来就是 >>> time.strptime('04/25/2005 10:19','%m/%d/%Y %H:%M') time.struct_time(tm_year=2005, tm_mon=4, tm_mday=25, tm_hour=10, tm_min=19, tm_sec=0, tm_wday=0, tm_yday=115, tm_is

我需要将Zope2DateTime对象转换为Python DateTime对象。最好的方法是什么?谢谢你,埃里卡,如果你是说

那么反过来就是

>>> time.strptime('04/25/2005 10:19','%m/%d/%Y %H:%M')
time.struct_time(tm_year=2005, tm_mon=4, tm_mday=25, tm_hour=10, tm_min=19, tm_sec=0, tm_wday=0, tm_yday=115, tm_isdst=-1)

datetime
实例是时区初始实例;如果您需要支持时区(正如Zope2的
DateTime
所做的那样),我建议使用第三方扩展包。

较新的DateTime实现(2.11及更高版本)有一个
asdatetime
方法返回python DateTime.DateTime实例:

modernthingy = zopethingy.asdatetime()
modernthingy = datetime.datetime.fromtimestamp(zopethingy.timeTime())
modernthingy = zopethingy.asdatetime()