Skip to content

Commit

Permalink
add test for issue #198
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Sep 25, 2020
1 parent 46d4f67 commit d5e8279
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/test_cftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,17 @@ def test_tz_naive(self):
cal = 'proleptic_gregorian'
dt2 = num2date(date2num(dt1, units, cal), units, cal)
assert(dt1 == dt2)
# issue #198 - cftime.datetime creates calendar specific datetimes that
# support addition/subtraction of timedeltas.
dt = cftime.datetime(2020, 1, 1, calendar='')
assert(isinstance(dt, cftime.datetime))
dt = cftime.datetime(2020, 1, 1, calendar="julian")
dt += timedelta(hours=1)
assert(str(dt) == '2020-01-01 01:00:00')
assert(isinstance(dt, cftime.DatetimeJulian))
for cal in cftime.DATE_TYPES.keys():
dt = cftime.datetime(2020, 1, 1, calendar=cal)
assert(isinstance(dt, cftime.DATE_TYPES[cal]))


class TestDate2index(unittest.TestCase):
Expand Down

0 comments on commit d5e8279

Please sign in to comment.