Read about our upcoming Code of Conduct on this issue

Commit 9f698f68 authored by nmartensen's avatar nmartensen
Browse files

append 'Z' to some datetime iso strings

--HG--
branch : 3.0
parent e287a114f30f
Pipeline #18761 passed with stage
in 6 minutes
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
import datetime import datetime
from openpyxl.compat import safe_string from openpyxl.compat import safe_string
from openpyxl.utils.datetime import (
CALENDAR_WINDOWS_1900,
to_ISO8601,
from_ISO8601,
)
from openpyxl.descriptors import ( from openpyxl.descriptors import (
String, String,
DateTime, DateTime,
...@@ -34,7 +29,7 @@ class NestedDateTime(DateTime, NestedText): ...@@ -34,7 +29,7 @@ class NestedDateTime(DateTime, NestedText):
tagname = "{%s}%s" % (namespace, tagname) tagname = "{%s}%s" % (namespace, tagname)
el = Element(tagname) el = Element(tagname)
if value is not None: if value is not None:
el.text = to_ISO8601(value) el.text = value.isoformat(timespec="seconds") + 'Z'
return el return el
......
...@@ -78,7 +78,7 @@ def test_from_tree(datadir, SampleProperties): ...@@ -78,7 +78,7 @@ def test_from_tree(datadir, SampleProperties):
def test_qualified_datetime(): def test_qualified_datetime():
from ..core import QualifiedDateTime from ..core import QualifiedDateTime
dt = QualifiedDateTime() dt = QualifiedDateTime()
tree = dt.to_tree("time", datetime.datetime(2015, 7, 20, 12, 30)) tree = dt.to_tree("time", datetime.datetime(2015, 7, 20, 12, 30, 00, 123456))
xml = tostring(tree) xml = tostring(tree)
expected = """ expected = """
<time xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="dcterms:W3CDTF"> <time xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="dcterms:W3CDTF">
...@@ -100,7 +100,7 @@ def dcterms_prefix(request): ...@@ -100,7 +100,7 @@ def dcterms_prefix(request):
def test_qualified_datetime_ns(dcterms_prefix): def test_qualified_datetime_ns(dcterms_prefix):
from ..core import QualifiedDateTime from ..core import QualifiedDateTime
dt = QualifiedDateTime() dt = QualifiedDateTime()
tree = dt.to_tree("time", datetime.datetime(2015, 7, 20, 12, 30)) tree = dt.to_tree("time", datetime.datetime(2015, 7, 20, 12, 30, 00, 987654))
xml = tostring(tree) # serialise to make remove QName xml = tostring(tree) # serialise to make remove QName
tree = fromstring(xml) tree = fromstring(xml)
xsi = tree.attrib["{%s}type" % XSI_NS] xsi = tree.attrib["{%s}type" % XSI_NS]
......
...@@ -18,6 +18,7 @@ import pytest ...@@ -18,6 +18,7 @@ import pytest
(datetime(2013, 7, 15, 6, 52, 33, 123456), "2013-07-15T06:52:33.123"), (datetime(2013, 7, 15, 6, 52, 33, 123456), "2013-07-15T06:52:33.123"),
(date(2013, 7, 15), "2013-07-15"), (date(2013, 7, 15), "2013-07-15"),
(time(0, 1, 42), "00:01:42"), (time(0, 1, 42), "00:01:42"),
(time(0, 1, 42, 123456), "00:01:42.123"),
] ]
) )
def test_to_iso(value, expected): def test_to_iso(value, expected):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment