当前位置: 首页>>代码示例>>Python>>正文


Python xmlrpclib.DateTime方法代码示例

本文整理汇总了Python中xmlrpclib.DateTime方法的典型用法代码示例。如果您正苦于以下问题:Python xmlrpclib.DateTime方法的具体用法?Python xmlrpclib.DateTime怎么用?Python xmlrpclib.DateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpclib的用法示例。


在下文中一共展示了xmlrpclib.DateTime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_dump_bare_datetime

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib 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_datetime set to 1 the unmarshaller would create
        # datetime objects for the 'datetime[123]' keys as well
        dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('20050210T11:41:23')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_xmlrpc.py

示例2: test_datetime_before_1900

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import DateTime [as 别名]
def test_datetime_before_1900(self):
        # same as before but with a date before 1900
        dt = datetime.datetime(1, 02, 10, 11, 41, 23)
        s = xmlrpclib.dumps((dt,))
        (newdt,), m = xmlrpclib.loads(s, use_datetime=1)
        self.assertEqual(newdt, dt)
        self.assertEqual(m, None)

        (newdt,), m = xmlrpclib.loads(s, use_datetime=0)
        self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_xmlrpc.py

示例3: test_cmp_datetime_DateTime

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import DateTime [as 别名]
def test_cmp_datetime_DateTime(self):
        now = datetime.datetime.now()
        dt = xmlrpclib.DateTime(now.timetuple())
        self.assertTrue(dt == now)
        self.assertTrue(now == dt)
        then = now + datetime.timedelta(seconds=4)
        self.assertTrue(then >= dt)
        self.assertTrue(dt < then) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_xmlrpc.py

示例4: test_bug_1164912

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib 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:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py

示例5: test_default

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import DateTime [as 别名]
def test_default(self):
        t = xmlrpclib.DateTime() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:4,代码来源:test_xmlrpc.py

示例6: test_time_tuple

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import DateTime [as 别名]
def test_time_tuple(self):
        d = (2007,6,9,10,38,50,5,160,0)
        t = xmlrpclib.DateTime(d)
        self.assertEqual(str(t), '20070609T10:38:50') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_xmlrpc.py

示例7: test_time_struct

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib 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:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_xmlrpc.py

示例8: test_datetime_datetime

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib 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:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_xmlrpc.py

示例9: test_repr

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib 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,项目名称:ironpython2,代码行数:7,代码来源:test_xmlrpc.py

示例10: test_decode

# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib 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(t1, tref) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_xmlrpc.py


注:本文中的xmlrpclib.DateTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。