Skip to content

Commit bf02909

Browse files
authored
Update to include MpasRelativeDelta class
1 parent 9781b43 commit bf02909

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

design_docs/timekeeping_reorg.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,46 @@ As long as `relativedelta` objects rather than `datetime.timedelta` objects are
104104
or the 365-day calendar.
105105

106106
<h2> Implementation: Capability of incrementing dates by a number of years and/or months <br>
107-
Date last modified: 2017/02/06 <br>
107+
Date last modified: 2017/02/09 <br>
108108
Contributors: Xylar Asay-Davis
109109
</h2>
110110

111111
The implementation is on the branch:
112112
https://github.com/xylar/MPAS-Analysis/tree/timekeeping_reorg
113113
and in PR #102
114114

115-
The proposed implementation uses `dateutil.relativedelta.relativedelta` to compute the expected
115+
The proposed implementation adds a new class MpasRelativeDelta derived from
116+
`dateutil.relativedelta.relativedelta` to compute the expected
116117
increments in years and months (as well as days, hours, minutes and seconds, as needed).
117-
The function for converting a date string to a `relativedelta` is documented as follows:
118+
The class is documented as follows
119+
```python
120+
class MpasRelativeDelta(relativedelta):
121+
"""
122+
MpasRelativeDelta is a subclass of dateutil.relativedelta for relative time
123+
intervals with different MPAS calendars.
124+
125+
Only relative intervals (years, months, etc.) are supported and not the
126+
absolute date specifications (year, month, etc.). Addition/subtraction
127+
of datetime.datetime objects (but not other MpasRelativeDelta,
128+
datetime.timedelta or other related objects) is supported.
129+
130+
Author
131+
------
132+
Xylar Asay-Davis
133+
134+
Last Modified
135+
-------------
136+
02/09/2017
137+
```
138+
139+
The function for converting a date string to a `MpasRelativeDelta` is documented as follows:
118140
```python
119141
from dateutil.relativedelta import relativedelta
120142
...
121143
def stringToRelativedelta(dateString, calendar='gregorian'):
122144
"""
123145
Given a date string and a calendar, returns an instance of
124-
`dateutil.relativedelta.relativedelta`
146+
`MpasRelativeDelta`
125147

126148
Parameters
127149
----------
@@ -147,7 +169,7 @@ def stringToRelativedelta(dateString, calendar='gregorian'):
147169

148170
Returns
149171
-------
150-
relativedelta : A `dateutil.relativedelta.relativedelta` object
172+
relativedelta : An `MpasRelativeDelta` object
151173

152174
Raises
153175
------
@@ -174,7 +196,9 @@ Analysis will be run on Edison with all available configurations found in `confi
174196
are currently no plans to run with the `gregorian` calendar option, we do not have test runs that use this
175197
calendar. If this situation changes in the future, we'll test at that time.
176198
177-
Regression tests previously for `Date` has been modified to test the new utility functions.
199+
Regression tests previously for `Date` has been modified to test the new utility functions. New tests
200+
have been added to test that dates with both `gregorian` and `gregorian_noleap` calendars behave as
201+
expected, particularly around the leap day.
178202
179203
<h1> Testing </h1>
180204
<h2> Testing and Validation: Capability of incrementing dates by a number of years and/or months <br>

0 commit comments

Comments
 (0)