本文整理汇总了Python中mx.DateTime.pydatetime方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.pydatetime方法的具体用法?Python DateTime.pydatetime怎么用?Python DateTime.pydatetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mx.DateTime
的用法示例。
在下文中一共展示了DateTime.pydatetime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DateTime
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import pydatetime [as 别名]
# Test values
pydt1 = datetime.datetime(2007, 1, 1, 12, 30, 13)
pydt2 = datetime.datetime(2007, 1, 1, 12, 30, 13, tzinfo=GMT1())
pyd1 = datetime.date(2007, 1, 1)
pyt1 = datetime.time(12, 30, 13)
pyt2 = datetime.time(12, 30, 13, tzinfo=GMT1())
pytd1 = datetime.timedelta(0, 12*3600 + 30*60 + 13)
mxdt1 = DateTime(2007, 1, 1, 12, 30, 13)
mxdt2 = DateTime(2007, 1, 1)
mxdt3 = DateTime(2007, 1, 1, 11, 30, 13)
mxdtd1 = DateTimeDelta(0, 12, 30, 13)
mxdtd2 = DateTimeDelta(0, 11, 30, 13)
# Constructor methods
assert mxdt1.pydate() == pyd1
assert mxdt1.pydatetime() == pydt1
assert mxdt1.pytime() == pyt1
assert mxdtd1.pytime() == pyt1
assert mxdtd1.pytimedelta() == pytd1
# Comparisons
assert pydt1 == mxdt1
assert mxdt1 == pydt1, (mxdt1, pydt1)
assert mxdt2 == pyd1
# Doesn't work, since datetime.time always compares false
# against non-datetime.time types
#assert pyt1 == mxdtd1
#assert mxdtd1 == pyt1
# Subtract
assert mxdt1 - pydt1 == 0.0