Skip to content

Commit

Permalink
change default to sep=' ' for backwards compatibility, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Apr 23, 2020
1 parent 0f1a6bf commit 1f6ec31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cftime/_cftime.pyx
Expand Up @@ -1355,7 +1355,7 @@ Gregorial calendar.
def __str__(self):
return self.isoformat()

def isoformat(self,sep='T',timespec='auto'):
def isoformat(self,sep=' ',timespec='auto'):
second = ":%02i" %self.second
if (timespec == 'auto' and self.microsecond) or timespec == 'microseconds':
second += ".%06i" % self.microsecond
Expand Down
7 changes: 7 additions & 0 deletions test/test_cftime.py
Expand Up @@ -747,6 +747,13 @@ def test_tz_naive(self):
# issue #165: make sure python datetime returned
d=num2date(0,units="seconds since 2000-01-01 00:00:00",only_use_cftime_datetimes=False)
assert isinstance(d, datetime)
# issue #152 add isoformat()
assert(d.isoformat()[0:24] == '2009-12-22 00:00:00.0156')
assert(d.isoformat(sep=' ')[0:24] == '2009-12-22 00:00:00.0156')
assert(d.isoformat(sep=' ',timespec='milliseconds') == '2009-12-22 00:00:00.015')
assert(d.isoformat(sep=' ',timespec='seconds') == '2009-12-22 00:00:00')
assert(d.isoformat(sep=' ',timespec='minutes') == '2009-12-22 00:00')
assert(d.isoformat(sep=' ',timespec='hours') == '2009-12-22 00')

class TestDate2index(unittest.TestCase):

Expand Down

0 comments on commit 1f6ec31

Please sign in to comment.