Skip to content
Snippets Groups Projects
Commit bcf87515e43c authored by jfp's avatar jfp
Browse files

Fix a regression when a str is used for a datetime vms argument.

parent 05f325154913
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,8 @@
def format_TIME(d, sub=2):
"""Format a DateTime object as a time value."""
if isinstance(d, str):
d = d.encode('iso-8859-1')
if isinstance(d, bytes):
try:
if sub > 0:
......@@ -74,8 +76,6 @@
d = d[: d.index(b'.') + sub]
except ValueError:
pass
if isinstance(d, str):
d = d.encode('iso-8859-1')
return d
if sub == 0:
subsec = ''
......@@ -90,6 +90,8 @@
def format_TIMESTAMP(d, sub=2):
"""Format a DateTime object as an ISO timestamp."""
if isinstance(d, str):
d = d.encode('iso-8859-1')
if isinstance(d, bytes):
try:
if sub > 0:
......@@ -97,8 +99,6 @@
d = d[: d.index(b'.') + sub]
except ValueError:
pass
if isinstance(d, str):
d = d.encode('iso-8859-1')
return d
if sub == 0:
subsec = ''
......@@ -113,6 +113,8 @@
def format_DateVMS(d, sub=2):
"""Format a DateTime object as an VMS timestamp."""
if isinstance(d, str):
d = d.encode('iso-8859-1')
if isinstance(d, bytes):
try:
if sub > 0:
......@@ -120,8 +122,6 @@
d = d[: d.index(b'.') + sub]
except ValueError:
pass
if isinstance(d, str):
d = d.encode('iso-8859-1')
return d
try:
ms = d.microsecond
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment