Fix iterating over DateTime by doing strict checking for Time objects

- Fixes #13667

(cherry picked from commit 1842a6920f6205262407ca893d31577f050b6b87)
Add CHANGELOG entry for #13668