本文整理汇总了Python中mx.DateTime.DateTime方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.DateTime方法的具体用法?Python DateTime.DateTime怎么用?Python DateTime.DateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mx.DateTime
的用法示例。
在下文中一共展示了DateTime.DateTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_datetime_timezone
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_parse_datetime_timezone(self):
# Time zone information is ignored.
from mx.DateTime import DateTime
expected = DateTime(2007, 1, 1, 13, 30, 29)
self.assertEqual(
expected, self.DATETIME("2007-01-01 13:30:29+01", self.curs))
self.assertEqual(
expected, self.DATETIME("2007-01-01 13:30:29-01", self.curs))
self.assertEqual(
expected, self.DATETIME("2007-01-01 13:30:29+01:15", self.curs))
self.assertEqual(
expected, self.DATETIME("2007-01-01 13:30:29-01:15", self.curs))
self.assertEqual(
expected, self.DATETIME("2007-01-01 13:30:29+01:15:42", self.curs))
self.assertEqual(
expected, self.DATETIME("2007-01-01 13:30:29-01:15:42", self.curs))
示例2: test_parse_bc_date
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_parse_bc_date(self):
value = self.DATE('00042-01-01 BC', self.curs)
self.assertTrue(value is not None)
# mx.DateTime numbers BC dates from 0 rather than 1.
self.assertEqual(value.year, -41)
self.assertEqual(value.month, 1)
self.assertEqual(value.day, 1)
示例3: test_parse_bc_datetime
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_parse_bc_datetime(self):
value = self.DATETIME('00042-01-01 13:30:29 BC', self.curs)
self.assertTrue(value is not None)
# mx.DateTime numbers BC dates from 0 rather than 1.
self.assertEqual(value.year, -41)
self.assertEqual(value.month, 1)
self.assertEqual(value.day, 1)
self.assertEqual(value.hour, 13)
self.assertEqual(value.minute, 30)
self.assertEqual(value.second, 29)
示例4: test_parse_time_timezone
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_parse_time_timezone(self):
# Time zone information is ignored.
from mx.DateTime import Time
expected = Time(13, 30, 29)
self.assertEqual(expected, self.TIME("13:30:29+01", self.curs))
self.assertEqual(expected, self.TIME("13:30:29-01", self.curs))
self.assertEqual(expected, self.TIME("13:30:29+01:15", self.curs))
self.assertEqual(expected, self.TIME("13:30:29-01:15", self.curs))
self.assertEqual(expected, self.TIME("13:30:29+01:15:42", self.curs))
self.assertEqual(expected, self.TIME("13:30:29-01:15:42", self.curs))
示例5: test_adapt_time
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_adapt_time(self):
from mx.DateTime import Time
value = self.execute('select (%s)::time::text',
[Time(13, 30, 29)])
self.assertEqual(value, '13:30:29')
示例6: test_adapt_bc_datetime
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_adapt_bc_datetime(self):
from mx.DateTime import DateTime
value = self.execute('select (%s)::timestamp::text',
[DateTime(-41, 1, 1, 13, 30, 29.123456)])
# microsecs for BC timestamps look not available in PG < 8.4
# but more likely it's determined at compile time.
self.assertTrue(value in (
'0042-01-01 13:30:29.123456 BC',
'0042-01-01 13:30:29 BC'), value)
示例7: test_adapt_timedelta
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [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)
示例8: test_adapt_negative_timedelta
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [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)
示例9: test_type_roundtrip_date
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_type_roundtrip_date(self):
from mx.DateTime import Date
self._test_type_roundtrip(Date(2010, 5, 3))
示例10: test_type_roundtrip_datetime
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_type_roundtrip_datetime(self):
from mx.DateTime import DateTime
self._test_type_roundtrip(DateTime(2010, 5, 3, 10, 20, 30))
示例11: test_type_roundtrip_interval
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_type_roundtrip_interval(self):
from mx.DateTime import DateTimeDeltaFrom
self._test_type_roundtrip(DateTimeDeltaFrom(seconds=30))
示例12: test_type_roundtrip_date_array
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_type_roundtrip_date_array(self):
from mx.DateTime import Date
self._test_type_roundtrip_array(Date(2010, 5, 3))
示例13: test_type_roundtrip_datetime_array
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_type_roundtrip_datetime_array(self):
from mx.DateTime import DateTime
self._test_type_roundtrip_array(DateTime(2010, 5, 3, 10, 20, 30))
示例14: test_type_roundtrip_time_array
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [as 别名]
def test_type_roundtrip_time_array(self):
from mx.DateTime import Time
self._test_type_roundtrip_array(Time(10, 20, 30))
示例15: test_type_roundtrip_interval_array
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import DateTime [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.