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


Python client.DateTime方法代碼示例

本文整理匯總了Python中xmlrpc.client.DateTime方法的典型用法代碼示例。如果您正苦於以下問題:Python client.DateTime方法的具體用法?Python client.DateTime怎麽用?Python client.DateTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在xmlrpc.client的用法示例。


在下文中一共展示了client.DateTime方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_datetime_before_1900

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1,  2, 10, 11, 41, 23)
        self.assertEqual(dt, xmlrpclib.DateTime('00010210T11:41:23'))
        s = xmlrpclib.dumps((dt,))

        result, m = xmlrpclib.loads(s, use_builtin_types=True)
        (newdt,) = result
        self.assertEqual(newdt, dt)
        self.assertIs(type(newdt), datetime.datetime)
        self.assertIsNone(m)

        result, m = xmlrpclib.loads(s, use_builtin_types=False)
        (newdt,) = result
        self.assertEqual(newdt, dt)
        self.assertIs(type(newdt), xmlrpclib.DateTime)
        self.assertIsNone(m) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:19,代碼來源:test_xmlrpc.py

示例2: deserialize

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def deserialize(self, blob):
        dt = self._handler.deserialize(blob)
        return xmlrpclib.DateTime(dt.timetuple()) 
開發者ID:openstack,項目名稱:oslo.serialization,代碼行數:5,代碼來源:msgpackutils.py

示例3: test_datetime

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_datetime(self):
        x = xmlrpclib.DateTime()
        x.decode("19710203T04:05:06")
        self.assertEqual(x, _dumps_loads(x)) 
開發者ID:openstack,項目名稱:oslo.serialization,代碼行數:6,代碼來源:test_msgpackutils.py

示例4: test_DateTime

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_DateTime(self):
        x = xmlrpclib.DateTime()
        x.decode("19710203T04:05:06")
        self.assertEqual('1971-02-03T04:05:06.000000',
                         jsonutils.to_primitive(x)) 
開發者ID:openstack,項目名稱:oslo.serialization,代碼行數:7,代碼來源:test_jsonutils.py

示例5: test_dump_bare_datetime

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_dump_bare_datetime(self):
        # This checks that an unwrapped datetime.date object can be handled
        # by the marshalling code.  This can't be done via test_dump_load()
        # since with use_builtin_types set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 2, 10, 11, 41, 23)
        self.assertEqual(dt, xmlrpclib.DateTime('20050210T11:41:23'))
        s = xmlrpclib.dumps((dt,))

        result, m = xmlrpclib.loads(s, use_builtin_types=True)
        (newdt,) = result
        self.assertEqual(newdt, dt)
        self.assertIs(type(newdt), datetime.datetime)
        self.assertIsNone(m)

        result, m = xmlrpclib.loads(s, use_builtin_types=False)
        (newdt,) = result
        self.assertEqual(newdt, dt)
        self.assertIs(type(newdt), xmlrpclib.DateTime)
        self.assertIsNone(m)

        result, m = xmlrpclib.loads(s, use_datetime=True)
        (newdt,) = result
        self.assertEqual(newdt, dt)
        self.assertIs(type(newdt), datetime.datetime)
        self.assertIsNone(m)

        result, m = xmlrpclib.loads(s, use_datetime=False)
        (newdt,) = result
        self.assertEqual(newdt, dt)
        self.assertIs(type(newdt), xmlrpclib.DateTime)
        self.assertIsNone(m) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:34,代碼來源:test_xmlrpc.py

示例6: test_bug_1164912

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_bug_1164912 (self):
        d = xmlrpclib.DateTime()
        ((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,),
                                            methodresponse=True))
        self.assertIsInstance(new_d.value, str)

        # Check that the output of dumps() is still an 8-bit string
        s = xmlrpclib.dumps((new_d,), methodresponse=True)
        self.assertIsInstance(s, str) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:test_xmlrpc.py

示例7: test_default

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_default(self):
        with mock.patch('time.localtime') as localtime_mock:
            time_struct = time.struct_time(
                [2013, 7, 15, 0, 24, 49, 0, 196, 0])
            localtime_mock.return_value = time_struct
            localtime = time.localtime()
            t = xmlrpclib.DateTime()
            self.assertEqual(str(t),
                             time.strftime("%Y%m%dT%H:%M:%S", localtime)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:test_xmlrpc.py

示例8: test_time

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_time(self):
        d = 1181399930.036952
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t),
                         time.strftime("%Y%m%dT%H:%M:%S", time.localtime(d))) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:test_xmlrpc.py

示例9: test_time_struct

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_time_struct(self):
        d = time.localtime(1181399930.036952)
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d)) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:test_xmlrpc.py

示例10: test_datetime_datetime

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_datetime_datetime(self):
        d = datetime.datetime(2007,1,2,3,4,5)
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t), '20070102T03:04:05') 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:test_xmlrpc.py

示例11: test_repr

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_repr(self):
        d = datetime.datetime(2007,1,2,3,4,5)
        t = xmlrpclib.DateTime(d)
        val ="<DateTime '20070102T03:04:05' at %#x>" % id(t)
        self.assertEqual(repr(t), val) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:7,代碼來源:test_xmlrpc.py

示例12: test_decode

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_decode(self):
        d = ' 20070908T07:11:13  '
        t1 = xmlrpclib.DateTime()
        t1.decode(d)
        tref = xmlrpclib.DateTime(datetime.datetime(2007,9,8,7,11,13))
        self.assertEqual(t1, tref)

        t2 = xmlrpclib._datetime(d)
        self.assertEqual(t2, tref) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:11,代碼來源:test_xmlrpc.py

示例13: test_comparison

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_comparison(self):
        now = datetime.datetime.now()
        dtime = xmlrpclib.DateTime(now.timetuple())

        # datetime vs. DateTime
        self.assertTrue(dtime == now)
        self.assertTrue(now == dtime)
        then = now + datetime.timedelta(seconds=4)
        self.assertTrue(then >= dtime)
        self.assertTrue(dtime < then)

        # str vs. DateTime
        dstr = now.strftime("%Y%m%dT%H:%M:%S")
        self.assertTrue(dtime == dstr)
        self.assertTrue(dstr == dtime)
        dtime_then = xmlrpclib.DateTime(then.timetuple())
        self.assertTrue(dtime_then >= dstr)
        self.assertTrue(dstr < dtime_then)

        # some other types
        dbytes = dstr.encode('ascii')
        dtuple = now.timetuple()
        with self.assertRaises(TypeError):
            dtime == 1970
        with self.assertRaises(TypeError):
            dtime != dbytes
        with self.assertRaises(TypeError):
            dtime == bytearray(dbytes)
        with self.assertRaises(TypeError):
            dtime != dtuple
        with self.assertRaises(TypeError):
            dtime < float(1970)
        with self.assertRaises(TypeError):
            dtime > dbytes
        with self.assertRaises(TypeError):
            dtime <= bytearray(dbytes)
        with self.assertRaises(TypeError):
            dtime >= dtuple 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:40,代碼來源:test_xmlrpc.py

示例14: test_repr

# 需要導入模塊: from xmlrpc import client [as 別名]
# 或者: from xmlrpc.client import DateTime [as 別名]
def test_repr(self):
        d = datetime.datetime(2007,1,2,3,4,5)
        t = xmlrpclib.DateTime(d)
        val ="<DateTime '20070102T03:04:05' at %x>" % id(t)
        self.assertEqual(repr(t), val) 
開發者ID:IronLanguages,項目名稱:ironpython3,代碼行數:7,代碼來源:test_xmlrpc.py


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