Skip to content

Commit

Permalink
fix for issue #169
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed May 6, 2020
1 parent 9adea4b commit 82d3898
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changelog
@@ -1,6 +1,8 @@
since version 1.1.2 release
===========================
* add isoformat method for compatibility with python datetime(issue #152).
* make 'proleptic_gregorian' default calendar for cftime.datetime
so that dayofwk,dayofyr methods don't fail (issue #169).

version 1.1.2 (release tag v1.1.2rel)
=====================================
Expand Down
4 changes: 2 additions & 2 deletions cftime/_cftime.pyx
Expand Up @@ -1254,7 +1254,7 @@ Gregorial calendar.

def __init__(self, int year, int month, int day, int hour=0, int minute=0,
int second=0, int microsecond=0, int dayofwk=-1,
int dayofyr = -1):
int dayofyr = -1, calendar='proleptic_gregorian'):

self.year = year
self.month = month
Expand All @@ -1263,7 +1263,7 @@ Gregorial calendar.
self.minute = minute
self.second = second
self.microsecond = microsecond
self.calendar = ""
self.calendar = calendar
self.datetime_compatible = True
self._dayofwk = dayofwk
self._dayofyr = dayofyr
Expand Down
4 changes: 4 additions & 0 deletions test/test_cftime.py
Expand Up @@ -754,6 +754,10 @@ 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 #169: cftime.datetime has no calendar attribute, causing dayofwk,dayofyr methods
# to fail.
c = cftime.datetime(*cftime._parse_date('7480-01-01 00:00:00'))
assert(c.strftime() == '7480-01-01 00:00:00')

class TestDate2index(unittest.TestCase):

Expand Down

0 comments on commit 82d3898

Please sign in to comment.