Repository: regro/regolith

Issue:
get_dates issues with date objects

Discussion:

Patch:
diff --git a/news/str_date.rst b/news/str_date.rst
new file mode 100644
index 00000000..a78872df
--- /dev/null
+++ b/news/str_date.rst
@@ -0,0 +1,12 @@
+**Added:** None
+
+**Changed:** None
+
+**Deprecated:** None
+
+**Removed:** None
+
+**Fixed:**
+    * get_dates function works with datetime objects and strings
+
+**Security:** None
diff --git a/regolith/dates.py b/regolith/dates.py
index 13680007..d07460fb 100644
--- a/regolith/dates.py
+++ b/regolith/dates.py
@@ -207,11 +207,20 @@ def get_dates(thing):
                                        month_to_int(thing['month']),
                                        thing['day'])
     if thing.get('begin_date'):
-        begin_date = date_parser.parse(thing.get('begin_date')).date()
+        if isinstance(thing.get('begin_date'), str):
+            begin_date = date_parser.parse(thing.get('begin_date')).date()
+        else:
+            begin_date = thing.get('begin_date')
     if thing.get('end_date'):
-        end_date = date_parser.parse(thing.get('end_date')).date()
+        if isinstance(thing.get('end_date'), str):
+            end_date = date_parser.parse(thing.get('end_date')).date()
+        else:
+            end_date = thing.get('end_date')
     if thing.get('date'):
-        date = date_parser.parse(thing.get('date')).date()
+        if isinstance(thing.get('date'), str):
+            date = date_parser.parse(thing.get('date')).date()
+        else:
+            date = thing.get('date')
     dates = {'begin_date': begin_date, 'end_date': end_date, 'date': date}
     return dates
 


Test patch:
diff --git a/tests/test_dates.py b/tests/test_dates.py
index 700519d5..10a3b890 100644
--- a/tests/test_dates.py
+++ b/tests/test_dates.py
@@ -15,6 +15,7 @@ TEST_DATE = date(2019, 6, 15)
 TEST_START_DATE = date(2019, 1, 1)
 TEST_END_DATE = date(2019, 2, 5)
 
+
 @pytest.mark.parametrize(
     "input,expected",
     [
@@ -156,6 +157,21 @@ def test_find_gaps_overlaps(input, flag, expected):
           'date': datetime.date(2020, 5, 20)
           }
          ),
+        ({'date': datetime.date(2020, 5, 20), 'begin_year': 2019, 'end_year': 2020,
+          'end_month': 'Feb',
+          'end_day': 10},
+         {'begin_date': datetime.date(2019, 1, 1),
+          'end_date': datetime.date(2020, 2, 10),
+          'date': datetime.date(2020, 5, 20)
+          }
+         ),
+        ({'date': datetime.date(2020, 5, 20), 'begin_date': datetime.date(2015, 6, 8),
+          'end_date': datetime.date(2025, 10, 4)},
+         {'begin_date': datetime.date(2015, 6, 8),
+          'end_date': datetime.date(2025, 10, 4),
+          'date': datetime.date(2020, 5, 20)
+          }
+         ),
     ],
 )
 def test_get_dates(input, expected):