@@ -85,6 +85,31 @@ def test_numpy_float32(self):
8585 self .assertIsInstance (result , float )
8686 self .assertAlmostEqual (result , 2.5 , places = 5 )
8787
88+ def test_python_datetime (self ):
89+ """datetime.datetime is converted to ISO 8601 string."""
90+ import datetime
91+
92+ dt = datetime .datetime (2024 , 6 , 15 , 10 , 30 , 0 )
93+ result = _normalize_scalar (dt )
94+ self .assertIsInstance (result , str )
95+ self .assertEqual (result , "2024-06-15T10:30:00" )
96+
97+ def test_python_date (self ):
98+ """datetime.date is converted to ISO 8601 string."""
99+ import datetime
100+
101+ d = datetime .date (2024 , 6 , 15 )
102+ result = _normalize_scalar (d )
103+ self .assertIsInstance (result , str )
104+ self .assertEqual (result , "2024-06-15" )
105+
106+ def test_numpy_datetime64 (self ):
107+ """np.datetime64 is converted to ISO 8601 string."""
108+ dt = np .datetime64 ("2024-06-15T10:30:00" )
109+ result = _normalize_scalar (dt )
110+ self .assertIsInstance (result , str )
111+ self .assertIn ("2024-06-15T10:30:00" , result )
112+
88113
89114class TestDataframeToRecords (unittest .TestCase ):
90115 """Unit tests for dataframe_to_records()."""
0 commit comments