Skip to content

Commit

Permalink
Add clarifying comments to Date testing
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Dec 8, 2016
1 parent 77d2e3a commit 419df44
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mpas_analysis/test/test_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def test_date(self):
timedelta2 = datetime.timedelta(days=20)
self.assertEqual(timedelta1, timedelta2)

# since pandas and xarray use the numpy type 'datetime[ns]`, which
# has a limited range of dates, the date 0001-01-01 gets increased to
# the minimum allowed year boundary, 1678-01-01 to avoid invalid
# dates.
date = Date(dateString='0001-01-01', isInterval=False)
datetime1 = date.to_datetime(yearOffset=0)
datetime2 = datetime.datetime(year=1678, month=1, day=1)
Expand All @@ -139,6 +143,10 @@ def test_date(self):
datetime2 = datetime.datetime(year=1850, month=1, day=1)
self.assertEqual(datetime1, datetime2)

# since pandas and xarray use the numpy type 'datetime[ns]`, which
# has a limited range of dates, the date 9999-01-01 gets decreased to
# the maximum allowed year boundary, 2262-01-01 to avoid invalid
# dates.
date = Date(dateString='9999-01-01', isInterval=False)
datetime1 = date.to_datetime(yearOffset=0)
datetime2 = datetime.datetime(year=2262, month=1, day=1)
Expand Down

0 comments on commit 419df44

Please sign in to comment.