當前位置: 首頁>>代碼示例>>Python>>正文


Python DateTime.DateTime方法代碼示例

本文整理匯總了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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:18,代碼來源:test_dates.py

示例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) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:9,代碼來源:test_dates.py

示例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) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:12,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:12,代碼來源:test_dates.py

示例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') 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:7,代碼來源:test_dates.py

示例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) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:11,代碼來源:test_dates.py

示例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) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:10,代碼來源:test_dates.py

示例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) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:10,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:5,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:5,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:5,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:5,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:5,代碼來源:test_dates.py

示例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)) 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:5,代碼來源:test_dates.py

示例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. 
開發者ID:iwitaly,項目名稱:psycopg2-for-aws-lambda,代碼行數:8,代碼來源:test_dates.py


注:本文中的mx.DateTime.DateTime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。