本文整理匯總了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.