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:
Victor Stinner 2023-06-14 17:00:40 +02:00 committed by GitHub
parent 7b1f0f204a
commit 307bceaa65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 32 deletions

View file

@ -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)