dates: do not crash when presented with a stdlib datetime object
2 files changed, 13 insertions(+), 8 deletions(-)

M test/test_api.py
M tshistory_client/api.py
M test/test_api.py +12 -7
@@ 223,13 223,18 @@ 2020-10-25 03:00:00+01:00    2.0
 2020-10-25 04:00:00+01:00    3.0
 """, ts)
 
-    with pytest.raises(AttributeError):
-        ts = client.get(
-            'test_dates',
-            revision_date=utcdt(2020, 10, 1),
-            from_value_date=pytz.UTC.localize(dt.datetime(2020, 10, 25)),
-            to_value_date=dt.datetime(2020, 10, 25, 4)
-        )
+    ts = client.get(
+        'test_dates',
+        revision_date=utcdt(2020, 10, 1),
+        from_value_date=pytz.UTC.localize(dt.datetime(2020, 10, 25)),
+        to_value_date=dt.datetime(2020, 10, 25, 3) # will be interpreted as utc
+    )
+    assert_df("""
+2020-10-25 00:00:00+00:00    0.0
+2020-10-25 01:00:00+00:00    1.0
+2020-10-25 02:00:00+00:00    2.0
+2020-10-25 03:00:00+00:00    3.0
+""", ts)
 
 
 def test_staircase_history(client):

          
M tshistory_client/api.py +1 -1
@@ 24,7 24,7 @@ def strft(dt):
     if is_naive:
         dt = pytz.UTC.localize(dt)
     else:
-        dt = dt.tz_convert('UTC')
+        dt = pd.Timestamp(dt).tz_convert('UTC')
 
     return dt.isoformat()