mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
xmlrpc.client uses datetime.datetime.isoformat() (#105741)
Reimplement _iso8601_format() using the datetime isoformat() method. Ignore the timezone. Co-Authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
This commit is contained in:
parent
7b1f0f204a
commit
307bceaa65
2 changed files with 12 additions and 32 deletions
|
@ -504,10 +504,16 @@ class DateTimeTestCase(unittest.TestCase):
|
|||
self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
|
||||
|
||||
def test_datetime_datetime(self):
|
||||
# naive (no tzinfo)
|
||||
d = datetime.datetime(2007,1,2,3,4,5)
|
||||
t = xmlrpclib.DateTime(d)
|
||||
self.assertEqual(str(t), '20070102T03:04:05')
|
||||
|
||||
# aware (with tzinfo): the timezone is ignored
|
||||
d = datetime.datetime(2023, 6, 12, 13, 30, tzinfo=datetime.UTC)
|
||||
t = xmlrpclib.DateTime(d)
|
||||
self.assertEqual(str(t), '20230612T13:30:00')
|
||||
|
||||
def test_repr(self):
|
||||
d = datetime.datetime(2007,1,2,3,4,5)
|
||||
t = xmlrpclib.DateTime(d)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue