本文整理汇总了Python中mx.DateTime.DateTimeDeltaFrom方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.DateTimeDeltaFrom方法的具体用法?Python DateTime.DateTimeDeltaFrom怎么用?Python DateTime.DateTimeDeltaFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mx.DateTime
的用法示例。
在下文中一共展示了DateTime.DateTimeDeltaFrom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_adapt_timedelta
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTimeDeltaFrom [as 别名]
def test_adapt_timedelta(self):
from mx.DateTime import DateTimeDeltaFrom
value = self.execute('select extract(epoch from (%s)::interval)',
[DateTimeDeltaFrom(days=42,
seconds=45296.123456)])
seconds = math.floor(value)
self.assertEqual(seconds, 3674096)
self.assertEqual(int(round((value - seconds) * 1000000)), 123456)
示例2: test_adapt_negative_timedelta
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTimeDeltaFrom [as 别名]
def test_adapt_negative_timedelta(self):
from mx.DateTime import DateTimeDeltaFrom
value = self.execute('select extract(epoch from (%s)::interval)',
[DateTimeDeltaFrom(days=-42,
seconds=45296.123456)])
seconds = math.floor(value)
self.assertEqual(seconds, -3583504)
self.assertEqual(int(round((value - seconds) * 1000000)), 123456)
示例3: test_type_roundtrip_interval
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTimeDeltaFrom [as 别名]
def test_type_roundtrip_interval(self):
from mx.DateTime import DateTimeDeltaFrom
self._test_type_roundtrip(DateTimeDeltaFrom(seconds=30))
示例4: test_type_roundtrip_interval_array
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTimeDeltaFrom [as 别名]
def test_type_roundtrip_interval_array(self):
from mx.DateTime import DateTimeDeltaFrom
self._test_type_roundtrip_array(DateTimeDeltaFrom(seconds=30))
# Only run the mx.DateTime tests if psycopg was compiled with support.